2014年5月26日星期一

sessionfactory injection error, beg master

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.hibernate.impl.SessionFactoryImpl' to required type ; 'org.hibernate.SessionFactory' for property 'sessionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.hibernate.impl . SessionFactoryImpl] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no ​​matching editors or conversion strategy found
applicationContet.xml

<-! root element of the Spring configuration file , use spring-beans-3.0.xsd semantic constraints - >
xmlns = "http://www.springframework.org/schema/beans"
xsi: schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">


<-! define a business logic components , to achieve class MyServiceImp ->
class = "org.crazyit.app.service.impl.MyServiceImpl">

<-! defined data source Bean, using C3P0 data source implementation - >
destroy-method = "close">
<-! Specifies the connection to the database driver - >

<-! URL specified connection to the database - >

<-! user name specified connection to the database - >

<-! Specifies the connection to the database password - >

<-! Specifies the connection to the database connection pool maximum number of connections - >

<-! Specifies the connection to the database connection pool minimum number of connections - >

<-! Specifies the connection to the database connection pool initialization connections - >

<-! Specifies the connection to the database connection pool maximum idle time - >


<-! define the Hibernate SessionFactory ->
class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<-! dependency injection data sources , into precisely defined above dataSource ->

<-! mappingResouces attribute is used to list all the mapping file - >


<-! used to list the following Hibernate mapping file - >
org / crazyit / app / domain / Person.hbm.xml


<-! defined Hibernate SessionFactory properties - >

<-! configure Hibernate Properties - >

hibernate.dialect = org.hibernate.dialect.OracleDialect
hibernate.hbm2ddl.auto = update
hibernate.show_sql = true
hibernate.format_sql = true;






<-! definitions DAO Bean ->
class = "org.crazyit.app.dao.impl.PersonDaoHibernate">
<-! inject persistence required to operate SessionFactory ->






Web.xml

xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "version =" 3.0 ">
<-! define the Web application home page - >

index.jsp

<-! location profiles Spring configuration file - >

<-! Use ContextLoaderListener to initialize the Spring container - >

org.springframework.web.context.ContextLoaderListener


<-! define Struts FilterDispathcer of Filter 2 's - >

struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

<-! FilterDispatcher used to initialize Struts 2 and WEB handle all requests . - >

struts2
/ *





------ Solution ------------------------------------ --------

Spring hibernate can manage , plus they reported the wrong Struts  

session factory using this org.hibernate.impl.SessionFactoryImpl look
------ For reference only ------------------ --------------------- did not see what the problem is on
configuration , ah, why should not you realize SessionFactory SessionFactoryImpl ah ?
------ For reference only -------------------------------------- -
look jar package
you use ------ For reference only --------------------------- ------------
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.hibernate. impl.SessionFactoryImpl 'to required type' org.hibernate.SessionFactory 'for property' sessionFactory '; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.hibernate.impl.SessionFactoryImpl] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found

SessionFactoryImpl can not be converted into org.hibernate.SessionFactory
------ For reference only ------------------- --------------------

antlr-2.7.6.jar, cglib-nodep-2.1_3.jar, com.springsource.org. aopalliance-1.0.0.jar, com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar, commons-collections-3.1.jar, commons-fileupload-1.2.1.jar, commons-io-1.3. 2.jar, commons-logging-api-1.1.jar, dom4j-1.6.1.jar, ejb3-persistence.jar, freemarker-2.3.16.jar, hibernate3.jar, javassist-3.12.0.GA.jar, jta-1.1.jar, ognl-3.0.jar, ojdbc14.jar, org.springframework.aop-3.0.5.RELEASE.jar, org.springframework.asm-3.0.5.RELEASE.jar, org.springframework.beans- 3.0.5.RELEASE.jar, org.springframework.context-3.0.5.RELEASE.jar, org.springframework.core-3.0.5.RELEASE.jar, org.springframework.expression-3.0.5.RELEASE.jar, org.springframework.jdbc-3.0.5.RELEASE.jar, org.springframework.orm-3.0.5.RELEASE.jar, org.springframework.transaction-3.0.5.RELEASE.jar, org.springframework.web-3.0. 5.RELEASE.jar, servlet-api.jar, slf4j-api-1.6.1.jar, slf4j-nop-1.6.1.jar, struts2-core-2.2.1.jar, struts2-spring-plugin-2.2. 1.jar, xwork-core-2.2.1.jar
------ For reference only ------------------------- --------------

just inherited HibernateDaoSupport, injecting sessionFactory they reported this wrong, very strange, configured to check for a long time did not find how can the problem
------ For reference only --------------------------------------- < br> http://docs.spring.io/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/HibernateDaoSupport.html

You can look api declaration must be injected org.hibernate.SessionFactory

------ For reference only ---------------------------------- -----
org.springframework.orm.hibernate3
Class LocalSessionFactoryBean

java.lang.Object
extended by org.springframework.orm.hibernate3.AbstractSessionFactoryBean
extended by org.springframework.orm.hibernate3.LocalSessionFactoryBean
All Implemented Interfaces:
BeanClassLoaderAware, DisposableBean, FactoryBean, InitializingBean, PersistenceExceptionTranslator
Direct Known Subclasses:
AnnotationSessionFactoryBean



little relationship with org.hibernate.SessionFactory destroy both have
------ For reference only ---------------------- -----------------
so either modify the DAO parent , or another sessionfactory
------ For reference only --- ------------------------------------

Spring can manage hibernate , plus Struts they reported on the wrong
------ For reference only ------------------------------- What --------
final solution is ? brother have encountered such a problem. Solving .

没有评论:

发表评论