[英]ClassDefNotFoundException even though the class is loaded by the classloaders (Multiple Applications are installed on the Server)
I have two Applications Installed on Websphere Server v.6. 我在Websphere Server v.6上安装了两个应用程序。 1. SGOApplication 2. ReportingWeb
1. SGOApplication 2. ReportingWeb
SGOApplication has a shared library mapped on Application Level ie SGOAPPSHLIB SGOApplication具有在应用程序级别(即SGOAPPSHLIB)映射的共享库
This library is having a logging framework jar(logsrv.jar). 该库具有日志记录框架jar(logsrv.jar)。 There is a class in logsrv.jar called SLEEventLogger which logs the messages to a file and uses some other third party classes which are all bundled in logsrv.jar
logsrv.jar中有一个名为SLEEventLogger的类,它将消息记录到文件中并使用其他一些第三方类,这些类都捆绑在logsrv.jar中
I want to use logsrv.jar for ReportingWeb Application . 我想将logsrv.jar用于ReportingWeb应用程序 。 I made a call for SLEEventLogger class from another class in ReportingWeb.
我从ReportingWeb的另一个类中调用了SLEEventLogger类。 I was able to build the ear and deploy it as logsrv.jar is there in the build path.
由于能够在构建路径中找到logsrv.jar,因此可以构建耳朵并进行部署。
After that, I tried following things, but none of them worked. 之后,我尝试了以下操作,但没有一个起作用。
I am getting ClassDefNotFoundException: com.statestreet.framework.logging.SLEEventLogger when trying to run webapplication and control reached that particular class where I used SLEEventLogger. 尝试运行Web应用程序时,我收到ClassDefNotFoundException:com.statestreet.framework.logging.SLEEventLogger ,并且控制权到达了我使用SLEEventLogger的特定类。
I tried to search for SLEEventLogger class from Troubleshooting>Classloader in websphere Console. 我试图从Websphere Console中的“疑难解答”>“类加载器”中搜索SLEEventLogger类。 I was able to find that SLEEventLogger class is being loaded by Module Class Loader.
我能够发现SLEEventLogger类正在由模块类加载器加载。
How to resolve this issue? 如何解决这个问题? I tried so many permutations and combinations on the server configuration but with no luck.
我在服务器配置上尝试了许多排列和组合,但是没有运气。 I am totally messed up with this.
我完全搞砸了。
To make this work you should: 要进行此工作,您应该:
WEB-INF/lib
) WEB-INF/lib
删除它) I think that you might have done part (1) in your third attempt, ie when you mapped REPSHLIB on server level. 我认为您可能已在第三次尝试中完成了第(1)部分,即在服务器级别上映射REPSHLIB时。 That's why it worked for ReportingWeb .
这就是为什么它适用于ReportingWeb的原因。 I guess that the reason it broke in SGOApplication is because SGOApplication probably already has a copy of logsrv.jar — that extra copy could conflict with the one loaded by the WebSphere classloader.
我猜想它在SGOApplication中损坏的原因是因为SGOApplication可能已经有一个logsrv.jar副本-多余的副本可能与WebSphere类加载器加载的副本冲突。 The key is to make sure that only one copy of the JAR is in any of the classloaders.
关键是要确保任何一个类加载器中都只有一个JAR副本。
See http://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer.html#N100F8 for a nice diagram of WebSphere's classloader hierarchy. 请参阅http://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer.html#N100F8 ,以获取WebSphere类加载器层次结构的详细图表。
I suggest DEBUG logging be enabled to give you a clearer picture of what is happening in your application. 我建议启用DEBUG日志记录,以使您更清楚地了解应用程序中正在发生的事情。
Of course, you mentioned that your logsrv.jar file was in your build path . 当然,您提到过您的logsrv.jar文件在构建路径中 。 It's worth noting that build path and your application's classpath may not in fact be one in the same.
值得注意的是, 构建路径和应用程序的类路径实际上可能并不相同。
According to the documentation for the NoClassDefFoundError exception, it's thrown when a class "existed when the currently executing class was compiled, but the definition can no longer be found." 根据NoClassDefFoundError异常的文档,当一个类“在当前正在执行的类被编译时已存在,但无法再找到其定义”时抛出。
In other words, the SLEEventLogger class was in your build path, allowing your application to compile, but the exception suggests that the JAR file containing this class is most likely not in your classpath. 换句话说,SLEEventLogger类位于您的构建路径中,从而允许您的应用程序进行编译,但是该异常表明,包含此类的JAR文件很可能不在您的类路径中。
When you try to run the application, the class that was compiled with knowledge that SLEEventLogger exists can no longer find it; 当您尝试运行该应用程序时,在知道存在SLEEventLogger的情况下编译的类将无法找到它。 as a result, a NoClassDefFoundError exception is thrown.
结果,将引发NoClassDefFoundError异常。
http://download.oracle.com/javase/1.4.2/docs/api/java/lang/NoClassDefFoundError.html http://download.oracle.com/javase/1.4.2/docs/api/java/lang/NoClassDefFoundError.html
This exception means that some class that com.statestreet.framework.logging.SLEEventLogger depends on, cannot be found. 此异常意味着无法找到com.statestreet.framework.logging.SLEEventLogger所依赖的某些类。 Meaning: the class com.statestreet.framework.logging.SLEEventLogger is found.
含义:找到类com.statestreet.framework.logging.SLEEventLogger。 But it depends on something that cannot be found, therefore it cannot be loaded.
但是它依赖于找不到的东西,因此无法加载。 If you have sources, you can easily find all classes com.statestreet.framework.logging.SLEEventLogger uses (just see imports).
如果您有资源,则可以轻松找到com.statestreet.framework.logging.SLEEventLogger使用的所有类(请参阅导入)。 Otherwise, you can try to decompile.
否则,您可以尝试反编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.