ClassLoader找不到在.war的WEB-INF/lib文件夹中存在的类。

huangapple go评论57阅读模式
英文:

ClassLoader can't find class that is present in .war's WEB-INF/lib folder

问题

抱歉,由于您的请求,我将只返回翻译好的部分,不包含代码。以下是翻译的内容:

So pretty suddenly, after updating some unrelated JNDI properties and after the deployments rebooted, I'm getting an error on one of them:
突然之间,在更新一些不相关的JNDI属性并重新部署后,我在其中一个部署中遇到了错误:

The error isn't triggered on deploying, but when the class is first needed.
这个错误不是在部署时触发的,而是在首次需要该类时出现。

When inspecting my .war, the WEB-INF/lib folder contains my-jar.jar which contains the ImportantClass class file.
检查我的.war文件时,WEB-INF/lib文件夹包含my-jar.jar,其中包含了ImportantClass类文件。

If it's of any importance: my-jar.jar is one of the modules of my second deployment, my-ear-deployment.ear, but the module is included in my .war during compile time.
如果有关系的话,my-jar.jar是我的第二个部署my-ear-deployment.ear的模块之一,但该模块在编译时包含在我的.war中。

I also tried it without compile in the POM on the needed module and it had the same result.
我还尝试过在所需模块的POM中去掉compile,但结果一样。

Any clues on what went wrong or how to fix it? Is it using the wrong class loader, since the needed class is inside a .jar? I'm no big DevOps expert unfortunately. We're using JBoss EAP 7.2.
关于出了什么问题以及如何修复它是否有任何线索?是否因为所需的类在一个.jar文件中,所以它使用了错误的类加载器?不幸的是,我不是一个很懂DevOps的专家。我们正在使用JBoss EAP 7.2。

英文:

So pretty suddenly, after updating some unrelated JNDI properties and after the deployments rebooted, I'm getting an error on one of them:

[TRACE] (ServerService Thread Pool -- 79) ..camel.util.ObjectHelper (485) Cannot load class: ImportantClass 
using classloader: ModuleClassLoader for Module "deployment.my-war-deployment.war" from Service Module Loader: 
java.lang.ClassNotFoundException: ImportantClass 
from [Module "deployment.my-war-deployment.war" from Service Module Loader]

The error isn't triggered on deploying, but when the class is first needed.

When inspecting my .war, the WEB-INF/lib folder contains my-jar.jar which contains the ImportantClass class file. If it's of any importance: my-jar.jar is one of the modules of my second deployment, my-ear-deployment.ear, but the module is included in my .war during compile time. I also tried it without <scope>compile</scope> in the POM on the needed module and it had the same result.

Any clues on what went wrong or how to fix it? Is it using the wrong class loader, since the need class is inside a .jar? I'm no big DevOps expert unfortunately. We're using JBoss EAP 7.2.

答案1

得分: 0

我找到了问题,与显示的错误消息完全无关(至少从我的角度来看):

我的.war文件正在寻找一个不存在的系统属性。不过,我不知道为什么这会导致类加载器异常,但我很高兴它已经修复了。

英文:

I found the problem, which was totally unrelated to the shown error message (at least from my PoV):

My .war was looking for a nonexistent system property. I have no idea how that resulted in the ClassLoader exception though, but I'm happy to have it fixed.

huangapple
  • 本文由 发表于 2023年2月24日 01:22:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548232.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定