Tuesday, May 10, 2016

WebLogic 10.3.x Error : NoSuchMethodError for javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode

As of now mostly trend is using newer frameworks or migrating from older framework to newer one.
One of the classic situation we started facing with Application Deployment once we have done migration.

Technology Stack we are using in our Applications is as below:
·         Java 7
·         JPA 2.0
·         Spring 3.0
·         Hibernate 3.0
·         EJB 3.0
·         Oracle 11g

While deploying we are getting below exception:
Caused By: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode;
at org.hibernate.ejb.util.LogHelper.logPersistenceUnitInfo(LogHelper.java:39)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:516)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:352)
at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:332)


In development environment we are using below for deployment:
·         WebLogic 12
·         Oracle 11g

So what is cause for this?
·         Pre-Production and Production environment having:
o   WebLogic 10.3.5
o   Oracle 11g

As database point of view there is no issue.
So it's mostly application server compatibility issue.
JPA Jars which WebLogic 10.3.5 is having are of different versions than application requires.

So as to resolve this issues, following are 2 possible solutions:
·         Application Level Changes:
o   Adding ANTLR specific changes to be done in weblogic-application.xml file located under META-INF.
<?xml version="1.0" encoding="UTF-8"?>


       <!--  This is needed since WL has a different version of antlr jar-->
    <prefer-application-packages>
        <package-name>antlr.*</package-name>
    </prefer-application-packages>
   
</weblogic-application>

o   Adding JPA specific JARs to application WAR/EAR only.
§  Hibernate-jpa-api.jar
§  Weblogic-fullclient.jar

·         WebLogic Level – Configuration changes:



--
III  Best Regards,
III  Abhijeet.

No comments: