spring+hibernate annotation 在JBoss下的错误处理

      spring+hibernate,基于annotation的ORM在tomcat5.5下运行正常,迁移到JBoss后,发布工程的时候出现如下错误:

11:03:41,109 INFO  [STDOUT] [ERROR,ContextLoader,main] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_filterChainProxyPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [config/hibernate/hibernate-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [config/hibernate/hibernate-context.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapab 

  

 

   关键的错误信息是这一段:

Invocation of init method failed; nested exception is org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)

 

hibernate的配置如下:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource" /></property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
				<prop key="hibernate.show_sql">false</prop>
			</props>
		</property>
		<property name="configLocation" value="classpath:/config/hibernate/hibernate.cfg.xml"/>
	</bean>
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property></bean>
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>

  

 

 

    各开源框架版本如下:

    Jboss  4.2.2

    spring  2.5.4

    hibernate 3.2

 

   解决办法:

 

   hibernate-annotations.jar版本过低。

   原文件版本信息:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_13-121 ("Apple Computer, Inc.")
Implementation-Title: Hibernate Annotations
Implementation-Version: 3.3.1.GA
Implementation-Vendor: hibernate.org
Implementation-Vendor-Id: hibernate.org
Implementation-URL: http://annotations.hibernate.org
Specification-Title: Java Persistence
Specification-Version: 1.0
Specification-Vendor: jcp.org

 

 

替换为3.2.0.GA: 

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_07-b03 (Sun Microsystems Inc.)
Product: Hibernate Annotations
Version: 3.2.0.GA

 

 

 

你可能感兴趣的:(java,spring,Hibernate,bean,jboss)