简体   繁体   中英

Deploy Spring Boot to weblogic 12

I have created an app(spring boot 1.5.6) using start.spring.io and trying to deploy it to Weblogic 12.1.3.0.0.
Messages in administration console:

Error Unable to access the selected application.
Error java.io.IOException
Error weblogic.utils.compiler.ToolFailureException

Message in logs:
<23.08.2017 13:40:26 GMT+03:00> <Error> <J2EE> <BEA-160228> <AppMerge failed to merge your application. If you are running AppMerge on the command-line, merge again with the -verbose option for more details. See the error message(s) below. >

These links don't help:
https://docs.spring.io/spring-boot/docs/1.5.x/reference/html/howto-traditional-deployment.html
Deploy Spring Boot app in Weblogic

Update:
The problem is dependency JAX-RS. Without it app is deployed successfully. Not sure how to make it work With this dependency
Update x2:
Removed Jax-rs and now:
java.lang.NoSuchMethodError:org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(Ljava/util/List;)V
Resolved by this

Our team started to use Spring Boot 2.0.0 and we had this issue also.

After some investigation, we have found that AppMerge tool scans all classes before deploy.

Root cause:

  • In case of WebLogic 12.1.3.* it fails because of Multi-Release JAR Files .
  • AppMerge tool can't work with JDK 9 files.

Solution:

  • Use Log4j 2.8.2

In pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project>
   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.0.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>
   ...
   <properties>
      ...
      <log4j2.version>2.8.2</log4j2.version>
      ...
   </properties>
   ...
</project>

I had this problem, and the answer by Artyom is correct, but I'll provide an answer to give some more details.

The problem in my case was Lombok. Any version after 1.6.20 (I believe) added Java 9 Module support. This adds a module-info.class in the root of the .jar file. I confirmed this was the problem by removing the module-info.class file from the jar and rebuilding my war. Appmerge was able to run successfully with this file removed. I would not suggest doing this in production, I just did it to confirm the problem. Not sure why Appmerge does not like module-info.class files.

Some advice that can help you troubleshoot this problem:

  • A simple method to identify the problematic dependency is to take a known project that works, then add dependencies from the failing project until the good project fails.

  • Extract the jar file for the broken dependency and look for a module-info.class file in the root directory. If it's there, this is likely the problem.

  • A useful command for testing if the .war merges: java -cp c:\path_to_weblogic_server\wlserver\server\lib\weblogic.jar weblogic.appmerge -verbose target/your_war_file.war . This will save you time trying to deploy in the console.

As for a solution for fixing the dependency besides reverting to an older version, I'm still trying to figure out.

Note : In the case of Lombok, I believe your supposed to set the scope to provided, which I wasn't doing in my case. The .jar won't be included when the scope is provided so you won't run into this problem. See this answer for more info.

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

Take note that Weblogc 12.1.3 is kind of particular, it is split between two java enterprise specifications 6 and 7.

  1. You will need to upgrade your JPA api and add the hibernate 5 implementation to your weblogic 12.1.3 instance.

  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.

I have mentioned the full description of steps here:

http://javagoogleappspot.blogspot.com/2018/05/make-your-spring-boot-20-compatible.html

After trying Arytom's solution without any luck, we tried investigating joshaidan's suggestion. Upon further digging we found the Oracle support document: 2645919.1

From that article:

Cause Application package contains incompatible jar library / class. WebLogic internally uses ASM library to check class bytecode version, it has following similar code to check bytecode version is compatible, or IllegalArgumentException will be thrown. https://github.com/llbit/ow2-asm/blob/master/src/org/objectweb/asm/ClassReader.java

166 public ClassReader(final byte[] b, final int off, final int len) {
167   this.b = b;
168   // checks the class version
169   if (readShort(off + 6) > Opcodes.V1_8) {
170     throw new IllegalArgumentException();
171   }

Update class file version to 53.0 When generating class files in conjunction with -target 9 (specified either explicitly or implicitly), javac will generate class files with a major version number of 53. For details of version 53 class files, see the Java Virtual Machine Specification. The JDK classes themselves mostly use version 53 class files. Tools or libraries that rely on ASM or other bytecode manipulation libraries may need updated versions of these libraries to work with version 53 class files.

Solution Replace the issue class/ library with compatible release.

[oracle@sandbox ~]$ cd ~/war
[oracle@sandbox war]$ for i in `find . -name '*.jar'`; do unzip -qo $i -d $i.delemete; done
[oracle@sandbox war]$ find . -name \*.class | xargs file | sort -t, -k2 | tail -n 10
./WEB-INF/js.jar.delemete/examples/webservices/jaxws/InvokeTransactionResponse.class:   compiled Java class data, version 52.0 (Java 1.8)
./WEB-INF/js.jar.delemete/examples/webservices/jaxws/MyClient$1.class:                  compiled Java class data, version 52.0 (Java 1.8)
./WEB-INF/js.jar.delemete/examples/webservices/jaxws/MyClient.class                     compiled Java class data, version 52.0 (Java 1.8)
./WEB-INF/js.jar.delemete/examples/webservices/jaxws/ObjectFactory.class:               compiled Java class data, version 52.0 (Java 1.8)
./WEB-INF/js.jar.delemete/examples/webservices/jaxws/package-info.class:                compiled Java class data, version 52.0 (Java 1.8)
./WEB-INF/js.jar.delemete/examples/webservices/jaxws/SimpleClientJwsImpl.class          compiled Java class data, version 52.0 (Java 1.8)
./WEB-INF/js.jar.delemete/examples/webservices/jaxws/SimpleClientService.class:         compiled Java class data, version 52.0 (Java 1.8)
./WEB-INF/lib/jackson-annotations-2.10.2.jar.delemete/module-info.class                 compiled Java class data, version 53.0
./WEB-INF/lib/jackson-core-2.10.2.jar.delemete/module-info.class:                       compiled Java class data, version 53.0
./WEB-INF/lib/jackson-databind-2.10.2.jar.delemete/module-info.class:                   compiled Java class data, version 53.0

The thing to note in the above example is that the last 3 lines are class files with version 53.0 , which are going to be the offending classes.

Upon investigation of our app, using Spring boot 1.5.6.RELEASE we found that the Jersey dependency was pulling in asm-all-repackaged:2.5.0-b32 which is compiled for JDK9. Adding the following explicit dependency addressed the issue, the solution to which was found here: https://github.com/jersey/jersey/issues/3617

<!--
            Work around bug where Jersey pulls in asm-all-repackaged:2.5.0-b32, which is compiled for JDK9. This prevents deployment to WebLogic 12.1.3 on JDK8
            https://github.com/jersey/jersey/issues/3617
            Oracle Support Doc ID 2645919.1
        -->
        <dependency>
            <groupId>org.glassfish.hk2.external</groupId>
            <artifactId>asm-all-repackaged</artifactId>
            <version>2.4.0</version>
        </dependency>

Try to remove dependency of tomcat:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

I faced same issue, and my solution is deleting weblogic.xml file in project folder.

I shared for whom concerned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM