1
votes

I am getting the exception in the title when I try to use Jenkins to deploy a WAR file to a WebLogic (12) server. When I deploy the same WAR file to my localhost WebLogic (10.3.6) everything works ok. I'm developing in NetBeans 7.4, which has Hibernate 3.6.10, and my local WebLogic has been updated to work with JPA 2.0.

I've tried everything I've seen on the Web but I can't resolve this error. My persistence.xml defines the persistence provider (Hibernate) and that's all. My weblogic.xml has the tags to use application JARS antlr.*, org.hibernate.*, and javax.persistence.* (I'm writing this from memory so bear with me a little). If I remove javax.persistence.* I get a java.lang.NoSuchFieldError: INSTANCE exception.

Everything I've read points to two different versions of persistence and that is causing the problems. I figured if I told weblogic to use everything that was copied into the WAR file (/lib) that it would use that. I can't give any information about the Web server because all I know is that it's using WebLogic 12.

Oh, one other thing, I'm not using Spring (which is what a lot of posts I read dealt with). I'm using Hibernate for persistence with an Oracle DB and the Web server is WebLogic 12.

Any thoughts or ideas?

Thanks.

2

2 Answers

2
votes

Weblogic 10.3.x which is JPA 1.0 compliant. To run JPA 2.0 application on weblogic 10.3.x,you will have to rename your persistence.xml to some other name like xyz.xml and configure it in Spring configuration file as shown below:

 <bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
     <property value="classpath:META-INF/xyz.xml" name="persistenceXmlLocation"/>
     <property name="persistenceUnitName" value="persistenceUnit"/>
     <property name="dataSource" ref="dataSource"/>
 </bean>

Rename the persistenceUnit and dataSource as per your beans in your application.

And define the package exclusions in weblogic.xml file as below:

<?xml version="1.0" encoding="UTF-8"?><wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.1/weblogic-web-app.xsd">
<wls:weblogic-version>10.3.3</wls:weblogic-version>
<wls:container-descriptor>
 <wls:index-directory-enabled>false</wls:index-directory-enabled>
<package-name>javax.persistence.spi.*</package-name> 
 <wls:prefer-application-packages>
   <wls:package-name>antlr.*</wls:package-name>
   <wls:package-name>org.apache.commons.*</wls:package-name>
   <wls:package-name>org.apache.xmlbeans.*</wls:package-name>
   <wls:package-name>org.springframework.*</wls:package-name>
   <wls:package-name>org.hibernate.*</wls:package-name>
   <wls:package-name>org.hibernate.validator.*</wls:package-name>
   <wls:package-name>javax.persistence.*</wls:package-name>
   <wls:package-name>org.joda.*</wls:package-name></wls:prefer-application-packages></wls:container-descriptor></wls:weblogic-web-app>
0
votes

Yes, this post is a little old but I did find out what was causing the issue about a month and a half after I asked the question.

The problem was that the workspace the project was being deployed to by Jenkins wasn't being properly cleaned out with every deployment, so there were, in fact, multiple versions of persistence. Unfortunately I had/have no control over anything Jenkins does exception schedule builds and the like so I was at the mercy of someone else, who, after six weeks of prodding, finally found out the workspace needed cleaning.

I hope this saves someone weeks of hair pulling.