简体   繁体   English

将 Spring Boot 部署到 weblogic 12

[英]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.我使用 start.spring.io 创建了一个应用程序(spring boot 1.5.6)并尝试将其部署到 Weblogic 12.1.3.0.0。
Messages in administration console:管理控制台中的消息:

Error Unable to access the selected application.错误无法访问选定的应用程序。
Error java.io.IOException错误 java.io.IOException
Error weblogic.utils.compiler.ToolFailureException错误 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 https://docs.spring.io/spring-boot/docs/1.5.x/reference/html/howto-traditional-deployment.html
Deploy Spring Boot app in Weblogic 在 Weblogic 中部署 Spring Boot 应用程序

Update:更新:
The problem is dependency JAX-RS.问题是依赖 JAX-RS。 Without it app is deployed successfully.没有它,应用程序将成功部署。 Not sure how to make it work With this dependency不知道如何使它与此依赖项一起工作
Update x2:更新 x2:
Removed Jax-rs and now:删除了 Jax-rs,现在:
java.lang.NoSuchMethodError:org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(Ljava/util/List;)V 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.我们的团队开始使用Spring Boot 2.0.0 ,我们也遇到了这个问题。

After some investigation, we have found that AppMerge tool scans all classes before deploy.经过一番调查,我们发现AppMerge工具在部署之前会扫描所有类。

Root cause:根本原因:

  • In case of WebLogic 12.1.3.* it fails because of Multi-Release JAR Files .WebLogic 12.1.3.*的情况下,由于Multi-Release JAR Files而失败。
  • AppMerge tool can't work with JDK 9 files. AppMerge工具无法处理JDK 9文件。

Solution:解决方案:

  • Use Log4j 2.8.2使用Log4j 2.8.2

In pom.xml :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.我遇到了这个问题,Artyom 的回答是正确的,但我会提供一个答案来提供更多细节。

The problem in my case was Lombok.我的问题是龙目岛。 Any version after 1.6.20 (I believe) added Java 9 Module support. 1.6.20 之后的任何版本(我相信)都添加了 Java 9 模块支持。 This adds a module-info.class in the root of the .jar file.这会在 .jar 文件的根目录中添加一个 module-info.class。 I confirmed this was the problem by removing the module-info.class file from the jar and rebuilding my war.我通过从 jar 中删除 module-info.class 文件并重建我的战争来确认这是问题所在。 Appmerge was able to run successfully with this file removed. Appmerge 能够在删除此文件后成功运行。 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.不知道为什么 Appmerge 不喜欢 module-info.class 文件。

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.提取损坏的依赖项的 jar 文件并在根目录中查找 module-info.class 文件。 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 .用于测试 .war 是否合并的有用命令: 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.注意:在 Lombok 的情况下,我相信您应该将范围设置为提供,而在我的情况下我没有这样做。 The .jar won't be included when the scope is provided so you won't run into this problem.提供范围时不会包含 .jar,因此您不会遇到此问题。 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. Spring boot 2.0 依赖于 JPA 2.1,而 Weblogic 12.1.3 vanilla 安装依赖于 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.请注意,Weblogc 12.1.3 有点特殊,它分为两个 Java 企业规范 6 和 7。

  1. You will need to upgrade your JPA api and add the hibernate 5 implementation to your weblogic 12.1.3 instance.您将需要升级您的 JPA api 并将 hibernate 5 实现添加到您的 weblogic 12.1.3 实例。

  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.在您的 Web 应用程序中,确保您拥有哪些依赖项,并且它们不会与 Weblogic 类加载器下已配置的依赖项重叠。

I have mentioned the full description of steps here:我在这里提到了步骤的完整描述:

http://javagoogleappspot.blogspot.com/2018/05/make-your-spring-boot-20-compatible.html 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.在尝试了 Arytom 的解决方案但没有成功后,我们尝试调查 joshaidan 的建议。 Upon further digging we found the Oracle support document: 2645919.1经过进一步挖掘,我们发现了 Oracle 支持文档:2645919.1

From that article:从那篇文章:

Cause Application package contains incompatible jar library / class.原因应用程序包中包含不兼容的 jar 库/类。 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. WebLogic 内部使用 ASM 库来检查类字节码版本,它有以下类似的代码来检查字节码版本是否兼容,否则将抛出 IllegalArgumentException。 https://github.com/llbit/ow2-asm/blob/master/src/org/objectweb/asm/ClassReader.java 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.将类文件版本更新为 53.0 结合 -target 9(显式或隐式指定)生成类文件时,javac 将生成主版本号为 53 的类文件。有关 53 版类文件的详细信息,请参阅 Java 虚拟机规格。 The JDK classes themselves mostly use version 53 class files. JDK 类本身主要使用 53 版的类文件。 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.依赖 ASM 或其他字节码操作库的工具或库可能需要这些库的更新版本才能使用 53 版类文件。

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.在上面的例子中要注意的是最后 3 行是版本为 53.0的类文件,它们将是有问题的类。

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.在调查我们的应用程序后,使用 Spring boot 1.5.6.RELEASE 我们发现 Jersey 依赖项正在拉入为 JDK9 编译的asm-all-repackaged:2.5.0-b32 Adding the following explicit dependency addressed the issue, the solution to which was found here: https://github.com/jersey/jersey/issues/3617添加以下显式依赖项解决了该问题,在此处找到了解决方案: 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:尝试删除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.我遇到了同样的问题,我的解决方案是删除项目文件夹中的weblogic.xml文件。

I shared for whom concerned.我为谁担心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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