java.lang.NoClassDefFoundError: Could not initialize class XXX

public class PropHolder { public static Properties prop; static { //code for loading properties from file } } // Referencing the class somewhere else: Properties prop = PropHolder.prop; class PropHolder is a class of my own. The class resides in the same JAR file of the main class. So that should not because any JAR … Read more

Getting java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory exception

i am executing simple Dependency Injection program of spring & getting this exception. I have already included common-logging1.1.1.jar and spring.jar file. Could you please help to out? Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:119) at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:55) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56) at com.client.StoryReader.main(StoryReader.java:15) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) … Read more

How can I solve “java.lang.NoClassDefFoundError”?

I’ve tried both the examples in Oracle’s Java Tutorials. They both compile fine, but at run time, both come up with this error: Exception in thread “main” java.lang.NoClassDefFoundError: graphics/shapes/Square at Main.main(Main.java:7) Caused by: java.lang.ClassNotFoundException: graphics.shapes.Square at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) … 1 more I think … Read more

What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?

What is the difference between NoClassDefFoundError and ClassNotFoundException? What causes them to be thrown? How can they be resolved? I often encounter these throwables when modifying existing code to include new jar files. I have hit them on both the client side and the server side for a java app distributed through webstart. Possible reasons … Read more

Getting java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory exception

i am executing simple Dependency Injection program of spring & getting this exception. I have already included common-logging1.1.1.jar and spring.jar file. Could you please help to out? Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:119) at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:55) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56) at com.client.StoryReader.main(StoryReader.java:15) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) … Read more