简体   繁体   English

奇怪的NoClassDefFoundError异常

[英]Strange NoClassDefFoundError exception

I am getting a bizarre case of NoClassDefFoundError exception. 我收到了NoClassDefFoundError异常的怪异案例。 My application is deployed on WebLogic 12c and been running there for several months. 我的应用程序已部署在WebLogic 12c上,并已在其中运行了几个月。 In one of the classes I am making a static invocation of the method defined in the class which is part of the JAR and that JAR is in the classpath of my Managed Server. 在其中一个类中,我将静态调用类中定义的方法,该类是JAR的一部分,并且JAR位于受管服务器的类路径中。 Everything was fine until one of a sudden I started to get "NoClassDefFoundError" for that particular class. 一切都很好,直到突然我开始为该特定类获取“ NoClassDefFoundError”。 My JAR hasn't changed, the calling class hasn't changed and the classpath hasn't changed. 我的JAR不变,调用类也没有变化,类路径也没有变化。 I checked CLASSPATH thru JVisualVM and my JAR file is there. 我通过JVisualVM检查了CLASSPATH,并且我的JAR文件在那里。

I am wondering is there any way to find out why it's happening through Java utilities or some other tools. 我想知道是否有任何方法可以找出为什么它是通过Java实用程序或其他一些工具发生的。

If it has been running for a long time, it is possible that your PermGen memory that contains static methods and class definitions has garbage collected that class definition in order to replace it with something else. 如果运行了很长时间,则包含静态方法和类定义的PermGen内存可能会垃圾回收该类定义,以便用其他内容替换它。 Once you try to call the static method, that class will once again be initialized but if at the moment of initialization something fails (for example you assign a static field's value from a static method that ends up throwing an exception) then the class won't be initialized and when you try to access it you will get a NoClassDefFoundError . 一旦您尝试调用静态方法,该类将再次被初始化,但是如果在初始化时失败(例如,您从静态方法中分配了静态字段的值,最终抛出了异常),则该类将不会初始化后,当您尝试访问它时,将收到NoClassDefFoundError

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM