当我们尝试在下面的DAO类中获取sessionFactory时,我们得到了错误:
Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.<init>(Lorg/hibernate/boot/spi/MetadataBuildingOptions;)V
<com.sun.xml.ws.server.sei.TieHandler> <TieHandler> <createResponse> <null>
java.lang.ExceptionInInitializerError
at gov.fda.ora.nfsdx.util.HibernateUtil.getSessionFactory(HibernateUtil.java:18)
at gov.fda.ora.nfsdx.dao.NfsdxDaoImpl.saveTransaction(NfsdxDaoImpl.java:66)
at gov.fda.ora.nfsdx.dao.NfsdxDaoImpl.saveData(NfsdxDaoImpl.java:119)
at gov.fda.ora.nfsdx.businessService.NfsdxBusinessServiceImpl.saveData(NfsdxBusinessServiceImpl.java:31)
at gov.fda.ora.nfsdx.service.NfsdxServicePortTypeImpl.submitInspectionResultsOperation(NfsdxServicePortTypeImpl.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:120)
at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:93)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:149)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:88)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:419)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:868)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:422)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:169)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:229)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:667)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:368)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:163)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:108)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:286)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:295)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:128)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:141)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:650)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:124)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:232)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:94)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:248)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:270)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.<init>(Lorg/hibernate/boot/spi/MetadataBuildingOptions;)V
at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.generateDefaultReflectionManager(MetadataBuilderImpl.java:742)
at org.hibernate.boot.internal.MetadataBuilderImpl$MetadataBuildingOptionsImpl.<init>(MetadataBuilderImpl.java:715)
at org.hibernate.boot.internal.MetadataBuilderImpl.<init>(MetadataBuilderImpl.java:127)
at org.hibernate.boot.MetadataSources.getMetadataBuilder(MetadataSources.java:135)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:654)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
at gov.fda.ora.nfsdx.util.HibernateUtil.getSessionFactory(HibernateUtil.java:13)
... 65 more
POM文件:下面是我们用来构建应用程序的maven POM。我们已经通过放置和改变jar的版本,但它没有工作。请帮助任何一个人。
<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>NfsdxApplication</groupId>
<artifactId>NfsdxWS</artifactId>
<version>1.0-SNAPSHOT</version>
<description>Generated POM from JDeveloper for project NfsdxWS</description>
<build>
<sourceDirectory>src/</sourceDirectory>
<resources>
<resource>
<directory>${basedir}</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
<outputDirectory>classes/</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/webapp/WEB-INF/lib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.oracle.adf.plugin</groupId>
<artifactId>ojdeploy</artifactId>
<version>12.2.1-2-0</version>
<configuration>
<ojdeploy>
${oracleHome}/jdeveloper/jdev/bin/ojdeploy.exe
</ojdeploy>
<workspace>
${basedir}/../NfsdxApplication.jws
</workspace>
<project>
NfsdxWS
</project>
<profile>
WebServices
</profile>
<outputfile>
${project.build.directory}/${project.build.finalName}.war
</outputfile>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.oracle.adf.library</groupId>
<artifactId>JAX-WS-Web-Services</artifactId>
<version>12.2.1-2-0</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.oracle.adf.library</groupId>
<artifactId>Oracle-JDBC</artifactId>
<version>12.2.1-2-0</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
</dependencies>
<properties>
<oracleHome>
${env.ORACLE_HOME}
</oracleHome>
</properties>
</project>
2条答案
按热度按时间zxlwwiss1#
你不需要包含hibernate-commons-annotations。注解现在包含在核心中。您的类路径上很可能有两个hibernate版本。您的应用服务器是否提供了不同版本的hibernate?
vyswwuz22#
在我的情况下,它有2个依赖,实际上有这个提到的类
和
因此,tomcat中抛出的错误是说它无法找到该类中的方法由以下原因引起:java.lang.NoSuchMethodError:org.hibernate.cfg.annotations.reflection.JPAMetadataProvider。但实际上它有多个文件具有相同的包或类,即使transative依赖是hibernate commons annotation,但它与hibernate annotations相同。
该方法的类org.hibernate.cfg.annotations.reflection.JPAMetadataProvider可从以下位置获得:我想下面的文字可能有助于快速跳转到问题。从中我可以说,它告诉删除多个依赖,这是传递在其他
jar:file:/home/ubuntu/tomcat/webapps/API/WEB-INF/lib/hibernate-annotations-3.5.6-Final.jar!/org/hibernate/cfg/annotations/reflection/JPAMetadataProvider.class jar:file:/home/ubuntu/tomcat/webapps/API/WEB-INF/lib/hibernate-core-5.4.12.Final.jar!/org/hibernate/cfg/annotations/reflection/JPAMetadataProvider.class