Friday, 18 May 2018

Make your Spring boot 2.0 compatible with Weblogic 12.1.3

You are struggling with a failed Spring Boot 2.0 deployment on Weblogic 12.1.3. This is due to the fact that Spring boot was added to the project as a dependency relying on a JPA specification that is not compatible with Weblogic 12.1.3. Unfortunately Weblogc 12.1.3 is split between two java enterprise specifications 6 and 7.

Please note that Spring boot 2.0 relies on JPA 2.1 while Weblogic 12.1.3 vanilla installation relies on JPA 1.0.

For more information, please read Oracle documentation at :

https://docs.oracle.com/middleware/1213/wls/NOTES/whatsnew.htm#NOTES309

Hence, you are required to ehance your Weblogic 12.1.3 instance with the JPA 2.1 Hibernate 5 implementation. The JPA 2.1 API and Hibernate 5 libraries need to be removed from the Quota-Prep artefact, that is, to be marked as provided.

Here is the list of actions needed to have a succesful deploy:

1. On your weblogic 12.1.3 instance, upgrade your JPA api and add the hibernate 5 implementation :

Make sure the following are deployed under the Weblogic classpath:





 
       


 

antlr-2.7.7.jar

classmate-1.3.4.jar

dir.txt

dom4j-1.6.1.jar

hibernate-commons-annotations-5.0.1.Final.jar

hibernate-core-5.2.16.Final.jar

hibernate-entitymanager-5.2.16.Final.jar

hibernate-envers-5.2.17.Final.jar

hibernate-infinispan-5.2.17.Final.jar

hibernate-jpa-2.1-api-1.0.0.Final.jar

hibernate-validator-5.2.5.Final.jar

jandex-2.0.3.Final.jar

javassist-3.22.0-GA.jar

javax.annotation-api-1.3.2.jar

javax.el-api-3.0.0.jar

javax.transaction-api-1.2.jar

jboss-logging-3.3.2.Final.jar

validation-api-2.0.1.Final.jar

       
 
 

 
 



When deploying locally,create a hibernate directory under your weblogic home directory, copy the above jars inside, and add the following snippet to load your classes in your bin\startWeblogic.cmd:

       
set WL_HOME=[pointing to your weblogic home]

SET PRE_CLASSPATH=%WL_HOME%\oracle_common\modules\javax.persistence_2.1.jar;%WL_HOME%\wlserver\modules\com.oracle.weblogic.jpa21support_1.0.0.0_2-1.jar;

SET HIBERNATE=%DOMAIN_HOME%\hibernate

SET PRE_CLASSPATH=%PRE_CLASSPATH%;%HIBERNATE%\antlr-2.7.7.jar;%HIBERNATE%\dom4j-1.6.1.jar;%HIBERNATE%\hibernate-commons-annotations-5.0.1.Final.jar;%HIBERNATE%\hibernate-core-5.2.16.Final.jar;%HIBERNATE%\classmate-1.3.4.jar;%HIBERNATE%\javax.el-api-3.0.0.jar

SET PRE_CLASSPATH=%PRE_CLASSPATH%;%HIBERNATE%\hibernate-entitymanager-5.2.16.Final.jar;%HIBERNATE%\hibernate-envers-5.2.17.Final.jar;%HIBERNATE%\hibernate-infinispan-5.2.17.Final.jar

SET PRE_CLASSPATH=%PRE_CLASSPATH%;%HIBERNATE%\hibernate-jpa-2.1-api-1.0.0.Final.jar;%HIBERNATE%\hibernate-validator-5.2.5.Final.jar;%HIBERNATE%\jandex-2.0.3.Final.jar;%HIBERNATE%\javassist-3.22.0-GA.jar

SET PRE_CLASSPATH=%PRE_CLASSPATH%;%HIBERNATE%\javax.annotation-api-1.3.2.jar;%HIBERNATE%\javax.transaction-api-1.2.jar;%HIBERNATE%\jboss-logging-3.3.2.Final.jar;%HIBERNATE%\validation-api-2.0.1.Final.jar

       
 




2. In you web app, make sure what dependencies you have and that they do not overlap with the ones already provisioned under Weblogic classloader.

Please execute the following command to have an understanding of your dependency tree:

mvn dependency:tree

Iidentify each of the jars mentioned above by its artefact id and group id and mark it as provided in the rest pom.xml

Here is an example :


       

<dependency>
        <groupid>org.apache.logging.log4j</groupid>
        <artifactid>log4j-api</artifactid>
        <scope>provided</scope>                   
    </dependency>
    <dependency>
        <groupid>org.hibernate</groupid>
        <artifactid>hibernate-core</artifactid>
        <scope>provided</scope>                   
    </dependency>
    <dependency>
        <groupid>org.hibernate.validator</groupid>
        <artifactid>hibernate-validator</artifactid>
        <scope>provided</scope>                   
    </dependency>   
    <dependency>
        <groupid>org.jboss.logging</groupid>
        <artifactid>jboss-logging</artifactid>
        <scope>provided</scope>                   
    </dependency>   
    <dependency>
        <groupid>com.fasterxml</groupid>
        <artifactid>classmate</artifactid>
        <scope>provided</scope>                   
    </dependency>
    <dependency>
        <groupid>javax.annotation</groupid>
        <artifactid>javax.annotation-api</artifactid>
        <scope>provided</scope>                   
    </dependency>
    <dependency>
        <groupid>javax.transaction</groupid>
        <artifactid>javax.transaction-api</artifactid>
        <scope>provided</scope>                   
    </dependency>
    <dependency>
        <groupid>javax.validation</groupid>
        <artifactid>validation-api    </artifactid>
        <scope>provided</scope>                   
    </dependency>


   
 

     



 Make sure also to not allow the spring boot maven plugin to add log4j-api to your archive. This API is already provided by Weblogic:

       
  <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
    <excludes>
        <exclude>
          <groupId>org.apache.logging.log4j.api</groupId>
 
          <artifactId>log4j-api</artifactId>
        </exclude>
   </excludes>
   </configuration>               
 
</plugin>


       
 
               

About Me

My Photo