在 websphere 6.0 中部署的类没有类定义错误
在Websphere 6.0 中,我部署了一个Web 应用程序“Project1”。我收到以下错误:- java.lang.NoClassDefFoundError: com.app.X 在 java.lang.Class.initialize(Class.java:318) 在 com.app.Y.invoke(Y.java:61) 处
,其中 com.app.X 和 com.app.Y 都是 \WEB-INF\lib 目录中存在的单独 jar 文件的一部分。 仅供参考,类加载策略是 ParentFirst/application。
我已经尝试多次部署并重新启动。知道我还能尝试什么吗?
感谢 Manglu 和 Bkail 的投入。但问题是包含 Y 类的 jar 与包含 X 类的 jar 一起在 java1.4 版本上编译。然而,由于我们的 CVS 系统错误检查,有人用不同版本的 java 编译了包含 X 类的 jar。因此,在运行时,当 Y 类的类加载器尝试查找 X 的特定类版本时,它找不到它。根据我的理解,在 J2EE/JAVA 环境中出现 noClassDefFound 错误有 4 个原因:- i) 类路径中实际缺少类 ii) 类存在但在类加载器层次结构中不可见 iii) 类存在,但版本不同。 iv) 如上所述,类存在,但在类初始化过程中遇到问题。
您还有什么要补充的吗?
In Websphere 6.0, I have a web application deployed "Project1". I am getting following error:-
java.lang.NoClassDefFoundError: com.app.X
at java.lang.Class.initialize(Class.java:318)
at com.app.Y.invoke(Y.java:61)
where both com.app.X and com.app.Y are part of separate jar files present in \WEB-INF\lib directory.
FYI, classloading policy is ParentFirst/application.
I have tried deployment multiple times and restart. Any clue what else I can try?
thanks Manglu and Bkail for your inputs. But issue was jar containing Y class was compiled on java1.4 version along with jar containing X class. However due to wrong checkin our CVS system, somebody compiled jar containing X class with different version of java. So during runtime, when Y class's classloader tried to locate the particular class version of X, it could not find it. Based on my understanding, there are 4 reasons why we can get noClassDefFound error in J2EE/JAVA environment:-
i) Class is actual missing in classpath
ii) Class is present but not visible in classloader hierarchy
iii) Class is present but it is of different version.
iv) As explained above, Class is present but having trouble in class initialization process.
Anything else do you want to add?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑 com.app.X 在其
方法中失败,这导致 JVM 将其标记为错误,并且引用该类的所有子序列尝试都将导致 NoClassDefFoundError。 1.5 JVM 在异常消息中包含(初始化失败)
标记,但 WAS 6.0 使用 1.4.2 JVM。查看日志中的com.app.X.
以查找失败的真正原因。I suspect that com.app.X failed in its
<clinit>
method, which causes the JVM to mark it as bad, and all subsequence attepmts to reference the class will result in NoClassDefFoundError. The 1.5 JVMs include a(initialization failure)
tag in the exception message, but WAS 6.0 uses 1.4.2 JVMs. Look through the logs forcom.app.X.<clinit>
to find the real cause of the failure.尝试为这里的人们提供堆栈跟踪来帮助您。
正如 bkail 提到的,看起来 com.app.X 在初始化过程中失败了,因此您收到了 NCDF 错误。
除非您明白 X 在初始化期间失败的原因,否则多次部署它不会有帮助。检查它是否有任何静态初始化块。
X 和 Y 都可能存在,并且对于由类加载器加载的 X,如果 X 依赖于不存在的 ABC,则可能会导致 X 出现 NCDF。
HTH
曼鲁
Try and provide the stack trace for the folks here to help you.
As bkail mentioned, it does look like com.app.X fails during its intialization as a result of which you receive a NCDF error.
Deploying it multiple times will not help unless you see why the X fail during its initialization. Check if it has any static initialization blocks.
Both X and Y may exist and for X to be loaded by the classloader if X depends on an ABC which is not present, it could result in NCDF for X.
HTH
Manglu