[英]Deploy Spring Boot to weblogic 12
我使用 start.spring.io 創建了一個應用程序(spring boot 1.5.6)並嘗試將其部署到 Weblogic 12.1.3.0.0。
管理控制台中的消息:
錯誤無法訪問選定的應用程序。
錯誤 java.io.IOException
錯誤 weblogic.utils.compiler.ToolFailureException
日志中的消息:
<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.
>
這些鏈接沒有幫助:
https://docs.spring.io/spring-boot/docs/1.5.x/reference/html/howto-traditional-deployment.html
在 Weblogic 中部署 Spring Boot 應用程序
更新:
問題是依賴 JAX-RS。 沒有它,應用程序將成功部署。 不知道如何使它與此依賴項一起工作
更新 x2:
刪除了 Jax-rs,現在:
java.lang.NoSuchMethodError:org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(Ljava/util/List;)V
由此解決
我們的團隊開始使用Spring Boot 2.0.0 ,我們也遇到了這個問題。
經過一番調查,我們發現AppMerge工具在部署之前會掃描所有類。
在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>
我遇到了這個問題,Artyom 的回答是正確的,但我會提供一個答案來提供更多細節。
我的問題是龍目島。 1.6.20 之后的任何版本(我相信)都添加了 Java 9 模塊支持。 這會在 .jar 文件的根目錄中添加一個 module-info.class。 我通過從 jar 中刪除 module-info.class 文件並重建我的戰爭來確認這是問題所在。 Appmerge 能夠在刪除此文件后成功運行。 我不建議在生產中這樣做,我只是為了確認問題。 不知道為什么 Appmerge 不喜歡 module-info.class 文件。
一些可以幫助您解決此問題的建議:
識別有問題的依賴項的一種簡單方法是獲取一個已知的有效項目,然后從失敗的項目中添加依賴項,直到好的項目失敗。
提取損壞的依賴項的 jar 文件並在根目錄中查找 module-info.class 文件。 如果它在那里,這很可能是問題所在。
用於測試 .war 是否合並的有用命令: java -cp c:\path_to_weblogic_server\wlserver\server\lib\weblogic.jar weblogic.appmerge -verbose target/your_war_file.war
。 這將節省您嘗試在控制台中部署的時間。
至於修復依賴關系的解決方案,除了恢復到舊版本,我還在想辦法。
注意:在 Lombok 的情況下,我相信您應該將范圍設置為提供,而在我的情況下我沒有這樣做。 提供范圍時不會包含 .jar,因此您不會遇到此問題。 有關更多信息,請參閱此答案。
Spring boot 2.0 依賴於 JPA 2.1,而 Weblogic 12.1.3 vanilla 安裝依賴於 JPA 1.0。
請注意,Weblogc 12.1.3 有點特殊,它分為兩個 Java 企業規范 6 和 7。
您將需要升級您的 JPA api 並將 hibernate 5 實現添加到您的 weblogic 12.1.3 實例。
在您的 Web 應用程序中,確保您擁有哪些依賴項,並且它們不會與 Weblogic 類加載器下已配置的依賴項重疊。
我在這里提到了步驟的完整描述:
http://javagoogleappspot.blogspot.com/2018/05/make-your-spring-boot-20-compatible.html
在嘗試了 Arytom 的解決方案但沒有成功后,我們嘗試調查 joshaidan 的建議。 經過進一步挖掘,我們發現了 Oracle 支持文檔:2645919.1
從那篇文章:
原因應用程序包中包含不兼容的 jar 庫/類。 WebLogic 內部使用 ASM 庫來檢查類字節碼版本,它有以下類似的代碼來檢查字節碼版本是否兼容,否則將拋出 IllegalArgumentException。 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 }
將類文件版本更新為 53.0 結合 -target 9(顯式或隱式指定)生成類文件時,javac 將生成主版本號為 53 的類文件。有關 53 版類文件的詳細信息,請參閱 Java 虛擬機規格。 JDK 類本身主要使用 53 版的類文件。 依賴 ASM 或其他字節碼操作庫的工具或庫可能需要這些庫的更新版本才能使用 53 版類文件。
解決方案將問題類/庫替換為兼容版本。
[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
在上面的例子中要注意的是最后 3 行是版本為 53.0的類文件,它們將是有問題的類。
在調查我們的應用程序后,使用 Spring boot 1.5.6.RELEASE 我們發現 Jersey 依賴項正在拉入為 JDK9 編譯的asm-all-repackaged:2.5.0-b32
。 添加以下顯式依賴項解決了該問題,在此處找到了解決方案: 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>
嘗試刪除tomcat的依賴:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
我遇到了同樣的問題,我的解決方案是刪除項目文件夾中的weblogic.xml文件。
我為誰擔心。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.