weblogic.management.DeploymentException:java.lang.NoSuchMethodError:javax.persistence.spi.PersistenceUnitInfo.getValidationMode()

时间:2018-05-28 17:28:50

标签: java-8 jpa-2.0 ejb-3.0 weblogic12c

在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”,该异常已从

解决

Error instantiating Persistence Provider class java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence

从那时起我就面临着这个例外

我在WL_DOMAIN / lib中提供了以下jar: -

  1. hibernate-jpa-2.0-api-1.0.1.Final
  2. com.oracle.jpa2support_1.0.0.0_2-1
  3. 休眠
  4. 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;

  5. 以下是异常的堆栈跟踪: -

       <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
     >
    

1 个答案:

答案 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。

来源: - https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=5zdu0pjx6_53&_afrLoop=302462572500859