将简单的Spring应用程序从Tomcat移动到Liberty不起作用

问题描述 投票:0回答:1

为了学习Spring,我创建了一个非常小的项目,并使用Gradle成功构建。然后我能够使用java -jar UserSettingController.war成功运行生成的.war,获取Spring消息:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::  (v2.1.0.BUILD-SNAPSHOT)

接下来,我想将它从Tomcat迁移到Websphere Liberty。所以,天真地,我将.war文件从我的project / build / libs /复制到相应的dropins文件夹,然后启动了Liberty服务器。那时,我在Liberty console.log中看到的不是Spring徽标,而是以下内容:

[WARNING ] CWWKC0044W: An exception occurred while scanning class and annotation data. The exception was java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at [internal classes]
.
[WARNING ] CWWKC0044W: An exception occurred while scanning class and annotation data. The exception was java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at [internal classes]
.
[WARNING ] CWWKC0044W: An exception occurred while scanning class and annotation data. The exception was java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at [internal classes]
.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://ui15-lin.utopusinsights.com:9080/UserSettingController/
[AUDIT   ] CWWKZ0001I: Application UserSettingController started in 4.829 seconds.
[AUDIT   ] CWWKF0012I: The server installed the following features: [jsp-2.2, servlet-3.1, ssl-1.0, jndi-1.0, websocket-1.0, json-1.0, localConnector-1.0, adminCenter-1.0, distributedMap-1.0, jaxrs-1.1, restConnector-1.0].
[AUDIT   ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.

我的问题是:那些[Warning]s很重要;如果是的话,问题是什么?或者应用程序实际上是通过Web服务器监听的,如果是,那么它正在侦听哪个端口(8080?)?

spring-boot websphere-liberty open-liberty
1个回答
1
投票

很可能,该应用程序包含一个具有java9功能的jar文件。

最简单的是,有一个普通的类已编译为java9。

更可能的是,应用程序已经引入了一个实用程序jar,例如log4j,它有一个“module-info”类,或者包含一个多版本目录(目前只有“META-INF / versions / 9”可能) 。

(有关多版本罐的更多信息,请参阅https://www.javaworld.com/article/3184029/java-language/java-9s-other-new-enhancements-part-4-multi-release-jar-files.html。)

“module-info”类文件将始终编译为java9或更高版本。多版本目录中的类将编译为java版本,该版本作为目录名称提供。

在所有情况下,如果类使用ASM到达注释处理,则会发生IllegalArgumentException。 (尝试加载类也会导致异常。)

问题出现在某种程度上,因为当前的WebSphere Liberty批注处理使用简单的测试来发现“类类型”资源,测试是测试类资源名称(文件或jar条目)是否以“.class”结尾。在引入module-info类型类之前和在META-INF文件夹下放置类之前,此测试就足够了。

作为更新,正在进行代码更改,这将防止处理问题类(类“module-info”或“META-INF”下的任何类)。有关更多信息,请参阅开放自由问题1635:https://github.com/OpenLiberty/open-liberty/issues/1635

关于解决问题的项目更新:我最好的感觉是项目更新会影响应用程序放入jar的内容,结果是不再放入带有java9功能的jar。

© www.soinside.com 2019 - 2024. All rights reserved.