在Weblogic:12.2.1上部署EJB应用程序时,我面临异常:
“weblogic.management.DeploymentException:java.lang.NoSuchMethodError:javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax / persistence / ValidationMode”
我在persistence.xml中有以下配置来指定持久性提供程序
<persistence-unit name="entityManager">
<!-- Use Hibernate persistency -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
weblogic-application.xml 中的及以下
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>javax.persistence.*</package-name>
在此异常之前,我遇到了异常“异常实例化持久性提供程序类java.lang.ClassNotFoundException:org.hibernate.ejb.HibernatePersistence”,该异常已从
解决从那时起我就面临着这个例外
我在WL_DOMAIN / lib中提供了以下jar: -
DOM4J
还在WL_DOMAIN中的下面文件的类路径中提供了如下所示 ---的setDomainEnv.cmd
设置EXT_PRE_CLASSPATH = C:\ Projects \ GMPP-CBOSS \ MFSS \ MFSS \ lib \ hibernate \ slf4j- api.jar文件; C:\项目\ GMPP-CBOSS \ MFSS \ MFSS \ lib中\休眠\冬眠-JPA-api.jar文件
--- TrivEnv.cmd
设置CLASSPATH = C:\ oracle \ Middleware2 \ modules \ javax.persistence_1.0.0.0_1-0- 2.jar; C:\ ORACLE \ Middleware2 \模块\ com.oracle.jpa2support_1.0.0.0_2- 1.jar;%CLASSPATH%
---- commonEnv.cmd ----- oracle_common / common / bin
设置CLASSPATH = C:\ oracle \ Middleware2 \ modules \ javax.persistence_1.0.0.0_1-0- 2.jar; C:\ ORACLE \ Middleware2 \模块\ com.oracle.jpa2support_1.0.0.0_2-1.jar;
以下是异常的堆栈跟踪: -
<28 May, 2018, 3:38:26,86 PM IST> <Warning> <Deployer> <WL-149078> <Stack
trace for message 149004
weblogic.management.DeploymentException: java.lang.NoSuchMethodError:
javax.persistence.spi.PersistenceUnitInfo.getValidationMode()
Ljavax/persistence/ValidationMode;
at weblogic.application.internal.BaseDeployment .throwAppException
(BaseDeployment.java:132)
at weblogic.application.internal.BaseDeployment.prepare
(BaseDeployment.java:242)
at weblogic.application.internal.EarDeployment.prepare
(EarDeployment.java:66)
at weblogic.application.internal. DeploymentStateChecker.prepare
(DeploymentStateChecker.java:158)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.
prepare(AppContainerInvoker.java:65)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError:
javax.persistence.spi.PersistenceUnitInfo.getValidationMode()
Ljavax/persistence/ValidationMode;
at org.hibernate.ejb.Ejb3Configuration.configure
(Ejb3Configuration.java:625)
at org.hibernate.ejb.HibernatePersistence.createContainer
EntityManagerFactory (HibernatePersistence.java:73)
at weblogic.persistence.BasePersistenceUnitInfo.initializeEntity
ManagerFactory(BasePersistenceUnitInfo.java:614)
at weblogic.persistence.BasePersistenceUnitInfo.
init(BasePersistenceUnitInfo.java:202)
at weblogic.persistence.BaseJPAIntegrationProvider.
createPersistenceUnitInfo(BaseJPAIntegrationProvider.java:54)
Truncated. see log file for complete stacktrace
>
答案 0 :(得分:0)
有可能在服务器类路径的开头和结尾添加了javax.persistence_1.0.0.0_2-0-0.jar(在DOMAIN_HOME / lib目录中)。
因此,同一服务器类路径中同一个jar的两个版本会导致不一致。
解 从DOMAIN_HOME / lib目录中删除javax.persistence_1.0.0.0_2-0-0.jar。