When you try to get JPA2 running on WebLogic 10.3 you might get this exception:

java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:632)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)

The reason is that WebLogic loads all JPA classes with the system classloader but ships JPA1. You have to force WebLogic to load the classes from within the lib folder of your web application.

Add to WEB-INF/weblogic.xml in your WAR project:

<wls:container-descriptor>
       <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
<wls:container-descriptor>

And additionally add to META-INF/weblogic-application.xml in your EAR project:

<wls:prefer-application-packages>
	<wls:package-name>javax.persistence.*</wls:package-name>
	<wls:package-name>org.hibernate.*</wls:package-name>
	<wls:package-name>org.springframework.*</wls:package-name>
</wls:prefer-application-packages>

It seems both is necessary.

4 thoughts on “Get JPA2 running on WebLogic 10.3

  1. Can I simply just say what a relief to discover someone who
    actually understands what they are talking about
    on the internet. You certainly understand how to bring an issue to
    light and make it important. More and more people need to look at this
    and understand this side of your story. I was surprised you’re not more popular since you
    certainly possess the gift.

  2. Hi……….i’m trying to delpoy my Jdeveloper application on standalone weblogic and i’m facing this problem:-No credential mapper entry found for password indirection user=hr for data source Connection1I resolved this problem by:-1. Right click on Application drop down select Application properties2. Click on Deployment3. Uncheck Auto Generate and Synchronize weblogic-jdbc.xml Descriptors During Deployment and I was able to solve this problem and delpoy my application but when i run my applicationI saw my jsf page but that jsf page was not Rendered and It showed all adf Tags…………Please Solve this problem……….

  3. If the majority of ratings are either 1-star or 5-star, then people are already using the rating they like best – I don't like it/I like it. So if people, when faced with a 5-level rating, unconsciously subvert into a love it/hate it thumbs up/thumbs down system, then that's the rating system they really prefer to use.What's going to be more fun is when you change the system to a binary one and people start complaining it's too limited. %)Kind of ironic, in a convoluted sort of way 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *


*