From: http://jroller.com/sjivan/entry/difference_between_classnotfoundexception_and_noclassdeffounderror
A ClassNotFoundException is thrown when the reported class is not found by the ClassLoader. This typically means that the class is missing from the CLASSPATH. It could also mean that the class in question is trying to be loaded from another class which was loaded in a parent classloader and hence the class from the child classloader is not visible. This is sometimes the case when working in more complex environments like an App Server (WebSphere is infamous for such classloader issues).
For example an exception (an error really since java.lang.NoClassDefFoundError is a subclass of java.lang.Error) like
java.lang.NoClassDefFoundError:
org/apache/activemq/ActiveMQConnectionFactory
does not mean that the ActiveMQConnectionFactory class is not in the CLASSPATH. Infact its quite the opposite. It means that the class ActiveMQConnectionFactory was found by the ClassLoader however when trying to load the class, it ran into an error reading the class definition. This typically happens when the class in question has static blocks or members which use a Class that's not found by the ClassLoader. So to find the culprit, view the source of the class in question (ActiveMQConnectionFactory in this case) and look for code using static blocks or static members.
On examining the code, say you find a line of code like below, make sure that the class SomeClass in in your CLASSPATH.
private static SomeClass foo = new SomeClass();
这种情况主要是编译时是有SomeClass的,运行时被删除找不到了就会报这种错误。
分享到:
相关推荐
类加载器是 Java 语言的一个创新,也是 ...不过如果遇到了需要与类加载器进行交互的情况,而对类加载器的机制又不是很了解的话,就很容易花大量的时间去调试 ClassNotFoundException和 NoClassDefFoundError等异常。
类加载器是 Java 语言的一个创新,也是 ...不过如果遇到了需要与类加载器进行交互的情况,而对类加载器的机制又不是很了解的话,就很容易花大量的时间去调试 ClassNotFoundException和 NoClassDefFoundError等异常。
ClassNotFoundException终极解决办法 完美解决ClassNotFoundException,jar包在线查找库,在线下载库
整个系统都没有错误,但是在发布运行后,控制台上却抛出了这样的异常: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
java.lang.NoClassDefFoundError: com/sun/activation/registries/LogSupport异常处理
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jersey/api/client/config/ClientConfig at org.apache.hadoop.yarn.client.api.TimelineClient.createTimelineClient(TimelineClient.java:...
JSON转化时出现 java.lang.ClassNotFoundException: net.sf.ezmorph.MorpherRegistry
java 9 中引入了模块的概念,默认情况下,Java SE中将不再包含java EE 的Jar包 而在 java 6/7 / 8 时关于这个API 都是捆绑在
JSP中ClassNotFoundException异常的解决办法.pdf 学习资料 复习资料 教学资源
java 找不到指定类时发生的异常(ClassNotFoundException) java 找不到指定类时发生的异常(ClassNotFoundException)
"java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver" 解决方案 [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. 解决了jsp连接 sql server 2000的问题
NULL 博文链接:https://sw1982.iteye.com/blog/607325
这个是我调用百度定位SDK做的一个小案例,但是在我电脑上能够运行,在其他人的电脑上就会报错,出现ClassNotFoundException异常。
NULL 博文链接:https://redarmychen.iteye.com/blog/463864
NULL 博文链接:https://chimpp55.iteye.com/blog/2344330
struts初学者的数据池配置出现java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource异常的解决办法
主要介绍了Exception in thread main java.lang.NoClassDefFoundError错误解决方法,需要的朋友可以参考下
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/ConditionalTagSupport 问题-附件资源
主要介绍了Android Caused by: java.lang.ClassNotFoundException解决办法的相关资料,需要的朋友可以参考下