即使类在编译时存在,也无法加载该类
在我们的项目中,我在部署代码时遇到以下异常。屏蔽类是一个实用程序类文件,无法加载运行时。尽管该类在编译时已存在,但为什么该类无法加载?
javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class com.***.****.****** at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:333) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) **** at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
In our project I am getting the following exception while deploying the code. The masked class is a utility class file which is failed to load runtime. Why is the class is failing to load though the class exists at compile time?
javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class com.***.****.****** at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:333) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) **** at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果任何
static
变量或static {}
块引发RuntimeException
(例如>NullPointerException
等)在类初始化期间。这个 RuntimeException 应该可以在堆栈跟踪中进一步看到。解释它并相应地修复代码。
This
NoClassDefFoundError
can occur if any of thestatic
variables orstatic {}
blocks threw anRuntimeException
(e.g.NullPointerException
, etc) during class initialization.This
RuntimeException
should be visible further down in the stacktrace. Interpret it and fix the code accordingly.我同意 BalusC 的观点。但请注意,根据您的具体情况,异常可能不会出现(在这种情况下,您只能被迫仔细观察)。较新的 JRE 好多了(尽管您在 weblogic 中运行,它可能会做一些奇怪的事情),我已经有一段时间没有遇到这个问题了,但曾几何时,它是我最大的 bug 熊之一。
I agree with BalusC. Note however that depending on your circumstance the exception may not surface (in which case you're just forced to look reaalllly closely). Newer JRE's are much better (although you are running within weblogic which could be doing a bunch of funky stuff) and I haven't had this issue for a while but once upon a time it was one of my biggest bug bears.