我用servlet / jsp和hibernate开发了一个web项目。它适用于Apache Tomcat 8 但是当更改为JBoss 7服务器时,发生了以下错误,无法使用JBoss服务器运行我的项目
有人可以解释发生了什么吗?
java.lang.ExceptionInInitializerError
com.auction.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:15)
com.auction.persistence.HibernateUtil.<clinit>(HibernateUtil.java:7)
com.auction.dao.daoimpl.UserDaoimpl.<init>(UserDaoimpl.java:17)
com.auction.servlet.TestThree.<init>(TestThree.java:17)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:526)
org.jboss.msc.value.ConstructedValue.getValue(ConstructedValue.java:61)
org.jboss.as.naming.ValueManagedReferenceFactory$1.getInstance(ValueManagedReferenceFactory.java:63)
org.jboss.as.ee.component.ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptor.java:52)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:151)
org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:76)
org.jboss.as.web.deployment.component.WebComponentInstantiator$1.<init> (WebComponentInstantiator.java:57)
org.jboss.as.web.deployment.component.WebComponentInstantiator.getReference(WebComponentInstantiator.java:55)
org.jboss.as.web.deployment.WebInjectionContainer.instantiate(WebInjectionContainer.java:99)
org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:78)
org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72)
org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
java.lang.Thread.run(Thread.java:724)
java.lang.NoSuchMethodError:
javax.persistence.Table.indexes()[Ljavax/persistence/Index;
org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936)
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3788)
org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3742)
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
com.auction.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:12)
com.auction.persistence.HibernateUtil.<clinit>(HibernateUtil.java:7)
com.auction.dao.daoimpl.UserDaoimpl.<init>(UserDaoimpl.java:17)
com.auction.servlet.TestThree.<init>(TestThree.java:17)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:526)
org.jboss.msc.value.ConstructedValue.getValue(ConstructedValue.java:61)
org.jboss.as.naming.ValueManagedReferenceFactory$1.getInstance(ValueManagedReferenceFactory.java:63)
org.jboss.as.ee.component.ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptor.java:52)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:151)
org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:76)
org.jboss.as.web.deployment.component.WebComponentInstantiator$1.<init> (WebComponentInstantiator.java:57)
org.jboss.as.web.deployment.component.WebComponentInstantiator.getReference(WebComponentInstantiator.java:55)
org.jboss.as.web.deployment.WebInjectionContainer.instantiate(WebInjectionContainer.java:99)
org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:78)
org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72)
org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
java.lang.Thread.run(Thread.java:724)
(注意: JBoss Web / 7.0.0.CR4日志中提供了根本原因的完整堆栈跟踪。)
这是maven依赖
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
答案 0 :(得分:0)
您可以通过使用'hibernate-jpa-2.1-api'替换位于jboss7 / modules / javax / persistence / api / main的JPA api jar文件来解决此问题。还可以在目录中更新module.xml。