Friday, May 10, 2024

3 ways to solve java.lang.NoClassDefFoundError in Java J2EE

I know how frustrating is to see "Exception in thread "main" java.lang.NoClassDefFoundError" while running your Java application. This is one of the dreaded problem in Java  which is also a manifestation of NoClassDefFoundError in Java. I have seen it a couple of times and spent quite a lot of time initially to figure out what is wrong, which class is missing etc. The first mistake I did was mingling java.lang.ClassNotfoundException and NoClassDefFoundError, in reality, are totally different, and my second mistake was using the trial and error method to solve this java.lang.NoClassDefFoundError instead of understanding why NoClassDefFoundError is coming, what is the real reason behind NoClassDefFoundError and how to resolve this.

In this Java tutorial, I have tried to rectify that mistakes and uncover some secrets of NoClassDefFoundError in Java and will share my experience around it. NoClassDefFoundError is not something that cannot be resolved or is hard to resolve it’s just its manifestation that puzzles most Java developers. 

This is also  the most common error in Java development along with java.lang.OutOfMemoroyError: Java heap space and java.lang.OutOfMemoryError: PermGen space  Anyway lets see Why NoClassDefFoundError comes in Java and what to do to resolve NoClassDefFoundError in Java.





What is the reason for NoClassDefFoundError in Java?

NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available at compile time. 

For example, if we have a method call from a class or accessing any static member of a class and that class is not available during run-time then JVM will throw NoClassDefFoundError

It’s important to understand that this is different than ClassNotFoundException which comes while trying to load a class at run-time only and the name was provided during runtime, not at compile-time. Many Java developer mingles this two Error and gets confused.




In short, NoClassDefFoundError will come if a class was present during compile time but not available in java classpath during runtime. Normally you will see the below line in the log when you get NoClassDefFoundError:

Exception in thread "main" java.lang.NoClassDefFoundError

Exception in thread “main” simply indicates that it's the “main” thread that is not able to find a particular class it could be any thread so just don’t worry. 

The difference between this error coming in the main thread and another thread is when Exception in thread “main” comes program crashes or shut itself down as opposed to other thread in which case your program will continue to run. 



Difference between java.lang.NoClassDefFoundError and ClassNotFoundException in Java

Many times we confused ourselves with java.lang.ClassNotFoundException and java.lang.NoClassDefFoundError, though both of them are related to Java Classpath they are completely different from each other. 

ClassNotFoundException comes when JVM tries to load a class at runtime dynamically means you give the name of the class at runtime and then JVM tries to load it and if that class is not found in the classpath it throws java.lang.ClassNotFoundException

While in the case of NoClassDefFoundError the problematic class was present during Compile time and that's why the program successfully compiled but was not available during runtime for any reason. 

NoClassDefFoundError is easier to solve than ClassNotFoundException in my opinion because here we know that Class was present at build time, but it totally depends upon the environment if you are working in the J2EE environment then you can get NoClassDefFoundError even if the class is present because it may not be visible to the corresponding class loader. 

3 ways to solve java.lang.NoClassDefFoundError in Java J2EE







How to resolve java.lang.NoClassDefFoundError in Java?

java.lang.NoClassDefFoundError in Java solutionThe obvious reason for NoClassDefFoundError is that a particular class is not available in Classpath, so we need to add that into Classpath or we need to check why it’s not available in Classpath if we are expecting it to be. There could be multiple reasons like:

1) The class is not available in Java Classpath.

2) You might be running your program using the jar command and class was not defined in the manifest file's ClassPath attribute.

3) Any start-up script is an overriding Classpath environment variable.

4) Because NoClassDefFoundError is a subclass of java.lang.LinkageError it can also come if one of it dependency like native library may not available.

4) Check for java.lang.ExceptionInInitializerError in your log file. NoClassDefFoundError due to the failure of static initialization is quite common.

5) If you are working in J2EE environment than the visibility of Class among multiple Classloader can also cause java.lang.NoClassDefFoundError, see examples and scenario section for detailed discussion.

We will now see a couple of examples and scenarios when java.lang.NoClassDefFoundError has come before and how it's been resolved. This can help you to troubleshoot the root cause of NoClassDefFoundError in Java application.

How to solve NoClassDefFoundError in Java


NoClassDefFoundError in Java - Example and Scenarios

1. A simple example of NoClassDefFoundError is class belongs to a missing JAR file or JAR was not added into classpath or sometimes jar's name has been changed by someone like in my case one of my colleagues has changed tibco.jar into tibco_v3.jar and the program is failing with java.lang.NoClassDefFoundError and I were wondering what's wrong.

2. The class is not in Classpath, there is no sure-shot way of knowing it but many times you can just have a look to print System.getproperty("java.classpath") and it will print the classpath from there you can at least get an idea of your actual runtime classpath.

3. Just try to run with explicitly -classpath option with the classpath you think will work and if it's working then it's a sure shot sign that someone is overriding java classpath.

NoClassDefFoundError in Java due to Exception in Static Initializer block

This is another common reason for java.lang.NoClassDefFoundError, when your class performs some static initialization in a static block like many Singleton classes initialized itself on the static block to take advantage of thread-safety provided by JVM during the class initialization process, and if static block throws an Exception, the class which is referring to this class will get NoclassDefFoundError in Java. 

If you look at your log file you should watch for any java.lang.ExceptionInInitializerError because that could trigger java.lang.NoClassDefFoundError: Could not initialize class on other places. 

Like in the below code example, During class loading and initialization User class are throwing Exception from the static initializer block, which triggers ExceptionInInitializerError during the first time loading of User class in response to new User() call.

Later rest of new User() are failing as java.lang.NoClassDefFoundError. the situation gets worst if original ExceptionInInitializerError, which is root cause here is silently eaten by any code.


Code Example of NoClassDefFoundError due to Static block Exception:


/**
 * Java program to demonstrate how failure of static initialization subsequently cause
 * java.lang.NoClassDefFoundError in Java.
 * @author Javin Paul
 */

public class NoClassDefFoundErrorDueToStaticInitFailure {

   
public static void main(String args[]){
       
        List
<User> users = new ArrayList<User>(2);
       
       
for(int i=0; i<2; i++){
           
try{
            users.
add(new User(String.valueOf(i))); //will throw NoClassDefFoundError
           
}catch(Throwable t){
                t.
printStackTrace();
           
}
       
}        
   
}
}

class User{
   
private static String USER_ID = getUserId();
   
   
public User(String id){
       
this.USER_ID = id;
   
}
   
private static String getUserId() {
       
throw new RuntimeException("UserId Not found");
   
}    
}

Output
java.lang.ExceptionInInitializerError
    at testing.NoClassDefFoundErrorDueToStaticInitFailure.main(NoClassDefFoundErrorDueToStaticInitFailure.java:23)
Caused by: java.lang.RuntimeException: UserId Not found
    at testing.User.getUserId(NoClassDefFoundErrorDueToStaticInitFailure.java:41)
    at testing.User.<clinit>(NoClassDefFoundErrorDueToStaticInitFailure.java:35)
    ... 1 more
java.lang.NoClassDefFoundError: Could not initialize class testing.User
    at testing.NoClassDefFoundErrorDueToStaticInitFailure.main(NoClassDefFoundErrorDueToStaticInitFailure.java:23)


5) Since NoClassDefFoundError is an also a LinkageError that arises due to dependency on some other class, you can also get java.lang.NoClassDefFoundError if your program is dependent on the native library and the corresponding DLL is not there. Remember this can also trigger java.lang.UnsatisfiedLinkError: no dll in java.library.path Exception Java. In order to solve this keep your dll along with JAR.

6) If you are using the ANT build file create JAR and manifest file then its worth noting to debug till that level to ensure that ANT build script is getting the correct value of classpath and appending it to manifest.mf file.

7) Permission issue on the JAR file can also cause NoClassDefFoundError in Java. If you are running your Java program in a multi-user operating system like Linux then you should be using the application user id for all your application resources like JAR files, libraries, and configuration. 

If you are using a shared library which is shared among multiple application which runs under different users then you may run into permission issue, like JAR file is owned by some other user and not accessible to your application.

One of our readers “it’s me said”, faced java.lang.NoClassDefFoundError due to this reason. See his comment also.




8) Typo on XML Configuration can also cause NoClassDefFoundError in Java. As most of Java frameworks like Spring, Struts they all use XML configuration for specifying beans. By any chance, if you put the bean name wrong, it may surface as java.lang.NoClassDefFoundError while loading other class which has a dependency on the wrongly named bean. 

This is quite common in the Spring MVC framework and Apache Struts where you get tons of Exception in thread "main" java.lang.NoClassDefFoundError, while deploying your WAR or EAR file.

9) Another example of java.lang.NoClassDefFoundError, as mentioned by our reader Nick, is that when your compiled class which is defined in a package, doesn’t present in the same package while loading like in the case of JApplet it will throw NoClassDefFoundError in Java. Also, see Nick’s comment on this error.


10) java.lang.NoClassDefFoundError can be caused due to multiple classloaders in J2EE environments. Since J2EE doesn’t mention standard classloader structure and it depends on different vendors like Tomcat, WebLogic, WebSphere on how they load different components of J2EE like WAR file or EJB-JAR file. 

In order to troubleshoot NoClassDefFoundError in the J2EE application knowledge of How ClassLoader works in Java is mandatory. Just to recap ClasLoader works on three principles delegation, visibility, and uniqueness. 

Delegation means every request to load a class is delegated to the parent classloader, visibility means an ability to found classes loaded by the classloader, all child classloaders can see classes loaded by parent classloader, but parent classloader can not see the class loaded by child classloaders. 

Uniqueness enforces that class loaded by the parent will never be reloaded by child classloaders. 

Now suppose if a class says User is present in both WAR file and EJB-JAR file and loaded by WAR classloader which is child classloader which loads the class from EJB-JAR. 

When a code in EJB-JAR refers to this User class, Classloader which loaded all EJB class doesn’t found that because it was loaded by WAR classloader which is a child of it. 

This will result in java.lang.NoClassDefFoundError for User class. Also, If the class is present in both JAR file and you will call equals method to compare those two objects, it will result in ClassCastException as the object loaded by two different classloaders can not be equal.



11) Some of the readers of this blog also suggested that they get Exceptions in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main , this error means either your Classpath, PATH  or JAVA_HOME is not setup properly or JDK installation is not correct. which can be resolved by reinstalling JDK? 

If you are getting this error try to reinstall JDK. One of our readers got this issue after installing JDK and then reinstalling JDK, he also has his JRE and JDK in a different folder. See his comment also by searching the version you have installed. 


12) Java program can also throw java.lang.NoClassDefFoundError during linking which occurs during class loading in Java. One of the examples of this scenario is just deleted the User class from our static initializer failure example after compilation and they try to run the program. 

This time, you will get java.lang.NoClassDefFoundError directly without  java.lang.ExceptionInInitializerError and message for NoClassDefFoundError are also just printing the name of the class as testing/User i.e. User class from the testing package. Watch out for this carefully as here root cause is absent of User.class file.

java.lang.NoClassDefFoundError: testing/User
    at testing.NoClassDefFoundErrorDueToStaticInitFailure.main(NoClassDefFoundErrorDueToStaticInitFailure.java:23)


Let me know how exactly you are facing NoClassDefFoundError in Java and I will guide you on how to troubleshoot it if you are facing something new way than I listed above we will probably document it for the benefit of others and again don’t be afraid with Exception in thread "main" java.lang.NoClassDefFoundError.  


Other Exception and Error handling Tutorials from Javareivisted

238 comments:

  1. I am getting java.lang.NoClassDefFoundError while running my program in Eclipse IDE. I checked the classpath and seems class is there. Eclipse is giving so much problem to me can any one help else has got NoClassDefFoundError in Eclipse ?

    ReplyDelete
  2. Can you post exact error or exception java.lang.NoClassDefFoundError comes due to many different reason.

    ReplyDelete
  3. NoClassDefFoundError mainly occurs at that time, when you have the class present in the JVM, however the JVM could not be able to load the class because of some reason (that can be either can exception is being thrown in the static block of the class) or for some other reason. However ClassNotFoundException seems to occur, while loading the main program, it does not found a class, which is being expected to be present.

    ReplyDelete
  4. Hi.. i am getting java.lang.ClassNotFoundException for many classes. error is being shown in the console while running the JUNIT. whereas the classes are being generated. can you please help me.

    ReplyDelete
  5. Hi Anusha, Can you post some error here, is related to JUnit ? ClassNotFoundException comes when JVM tries to load class as result of method call Class.forName(), ClassLoader.findSystemClass() or ClassLoader.loadClass()

    ReplyDelete
  6. yeah, i am getting this exception when trying to run JUNIT.below is the exception.


    java.lang.ClassNotFoundException:
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:425)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    ReplyDelete
  7. Hi Anusha, do you have JUnit library added in your buildpath, you can check it by right click on your project --> properties-->Java build Path-->library, if not then you can add there as Add library -->Junit. if yes then it may possible that some of the jar in your build path is not present ( int his case your project must have some erorr) due to which Eclipse not able to find JUnit classes.

    you can isolate this by running a simple Junit test on other project.

    ReplyDelete
  8. should be System.getProperty("java.class.path") instead of System.getproperty("java.classpath"), at least for jdk1.6.0_25.

    ReplyDelete
  9. iam also getting same error when trying to start the Tomcat service.Below is info
    Caused by: java.lang.NoClassDefFoundError: org/apache/naming/resources/ProxyDirContext
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
    at java.lang.Class.getConstructor0(Class.java:2640)
    at java.lang.Class.newInstance0(Class.java:321)
    at java.lang.Class.newInstance(Class.java:303)
    at org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:253)
    at org.apache.commons.digester.Rule.begin(Rule.java:200)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1273)
    at org.apache.catalina.util.CatalinaDigester.startElement(CatalinaDigester.java:65)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digester.java:1548)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:489)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:528)
    ... 6 more

    ReplyDelete
  10. I am getting this error when runing a SAS program

    Java virtual machine exception. java.lang.NoClassDefFoundError:
    com/sun/java/swing/SwingUtilities2

    Is it the same as the discussion above? If yes, how do I fix it?

    ~Anusha D.

    ReplyDelete
  11. /red5# sh red5.sh
    Running on Linux
    Starting Red5
    Picked up _JAVA_OPTIONS: -Xms64M -Xmx128m
    Exception in thread "main" java.lang.NoClassDefFoundError: &LOGGING_OPTS
    Caused by: java.lang.ClassNotFoundException: &LOGGING_OPTS
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Could not find the main class: &LOGGING_OPTS. Program will exit.

    What`s wrong?!

    ReplyDelete
  12. Hello, I'm running an ImageJ plugin called PTA, and I get this error when I try to run the plugin.

    Plugin or class not found: "PTA_"
    (java.lang.NoClassDefFoundError: Could not initialize class PTA_)

    I'm sure I placed the necessary files in the correct locations, according to a manual specifically for PTA. I can't seem to solve the problem- do you have any suggestions/advice?

    ReplyDelete
  13. Please check you have similar versions of JRE. Many times it happened with me that my classes were compiled with JRE 1.5.2 and I was deploying them on a server which was using JRE 1.5.0. Make sure you compile using the server's JRE and then try again.

    ReplyDelete
  14. Hi, I am trying to use display tag library in my jsp page for showing some data in tabular format but while running that jsp page I am getting NoClassDefFoundError.

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/UnhandledException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.newInstance0(Class.java:326)
    at java.lang.Class.newInstance(Class.java:308)

    What is the cause of NoClassDefFoundError here ?

    ReplyDelete
  15. Hi Anonymoust.Displaytag has dependency on some third party jars like apache commons lang, poi , tyring adding all those library and you will be fine. a quick ways is to download display tag example war file comes along with display tag download in source forge site and then use all jars from the /WEB-INF/lib in your project and you will be free of Exception in thread "main" java.lang.NoClassDefFoundError:

    ReplyDelete
  16. i am using google map library in my android application where i am extending MapActivity in my application.Now i am getting NoClassDefFound while opening this activity. I am developing this project in Eclipse 3.6 under google api 2.2and running on emulator with google api 2.2. i even set maps library of android sdk in my build path of project. Please help me.

    ReplyDelete
  17. Hi,

    I have written a filter to authorize my application which takes ldap details from context.xml. I have used spring to create objects to the bean in the context.xml and to work with it. context.xml contains only one bean, named "directory".

    I am getting the below error while running the application. Can any one help me..


    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'directory' defined in class path resource [config/DEV/beanContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError

    ReplyDelete
  18. Hi Anand can you post full error for which class its giving java.lang.NoClassDefFoundError ?

    ReplyDelete
  19. Hi,

    I'm trying to get a class to run in an Eclipse project. When I try to run it I get the following exception:

    java.lang.NoClassDefFoundError: com/scivantage/middleware/maxit/dashboard/MaxitAccountOverviewServer
    Caused by: java.lang.ClassNotFoundException: com.scivantage.middleware.maxit.dashboard.MaxitAccountOverviewServer
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Exception in thread "main"

    It doesn't seem right that I can't generate the byte code for the class 'till I have the byte code for that class.

    Any suggestions?

    ReplyDelete
  20. Hi
    I got the error message when moving the files from old mechine to a new mechine
    this code for displaying captcha (cap.jsp)

    please help me

    type Exception report
    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: /opt/j2sdk_nb/j2sdk1.4.2/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
    org.apache.jsp.cap_jsp._jspService(cap_jsp.java:218)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    root cause

    java.lang.UnsatisfiedLinkError: /opt/j2sdk_nb/j2sdk1.4.2/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
    java.lang.ClassLoader$NativeLibrary.load(Native Method)
    java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
    java.lang.ClassLoader.loadLibrary(ClassLoader.java:1477)
    java.lang.Runtime.loadLibrary0(Runtime.java:788)
    java.lang.System.loadLibrary(System.java:834)
    sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
    java.security.AccessController.doPrivileged(Native Method)
    java.awt.Toolkit.loadLibraries(Toolkit.java:1437)
    java.awt.Toolkit.(Toolkit.java:1458)
    java.awt.Color.(Color.java:250)
    org.apache.jsp.cap_jsp._jspService(cap_jsp.java:86)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

    ReplyDelete
  21. Looks like in your new machine either Java is not installed on /opt or installed as different version because it clearly says:

    "/opt/j2sdk_nb/j2sdk1.4.2/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory"

    ReplyDelete
  22. Hi,

    First, thanks for the post. I have the same problem. I use eclipse, and when i do system.getproperty("java.classpath"), the code prints "null", in every project that i have...

    All the JAR are added in the project, and i get:
    Exception in thread "main" java.lang.NoClassDefFoundError: mss/comm/winBT/WinBT
    at mss.communication.Communication.(Communication.java:16)
    at mss.comm.win.Main.(Main.java:39)
    at mss.comm.win.Main.main(Main.java:99)
    Caused by: java.lang.ClassNotFoundException: mss.comm.winBT.WinBT

    The problem Exception cames when i try to initialize the class "mss/comm/winBT/WinBT" from "mss.communication.Communication". Can you help me?

    ReplyDelete
  23. Hi,
    I have problem with

    Exception in thread "main" java.lang.NoClassDefFoundError: Filed

    The situation is my uni is marking our java assignment using a system called Plate.

    \\\\\\\\
    The root class must be named Trader and must include a static main method for your
    code to be marked by PLATE. You must have the first two lines of code for PLATE to run. The
    code inside the method should contain only a call to the constructor, as shown
    public class Trader
    { public static void main(String[] args)
    { new Trader (); }
    \\\\\\\\\

    I use BlueJ as the IDE. My code runs if I run the main method, but is not running after I exported to jar file. When exporting, I chose, include source, Main clas: Trader. Here is my jar, if you can take a look at it, that will be great.

    http://users.tpg.com.au/anitaguo//a1File.jar

    ReplyDelete
  24. Thanks a lot!

    >2) You might be running your program using jar >command and class was not defined in manifest file's >ClassPath attribute.
    Pointed me to my mistake, which i just spent 2h or so.
    Run a *.jar without java -jar option and you get the same error, with all classes being where they should be.

    ReplyDelete
  25. Hi,

    I have blackberry 8700, and i installed spy cell phone software on my blackberry, but when i use to run the application, it gives an error saying "java.lang.NoClassDefFoundError"

    Can any one help how to get rid of this error?

    Thanks

    ReplyDelete
  26. I could add some light. For those who use Eclipse if you right clicked on the server > "Publish" then you'll get this error. I solved right clicking on the server > "Clean". My code was ok. I just don't know what are those Eclipse options.

    ReplyDelete
  27. One of my libraries was giving NoClassDefFoundError because of its dependency on native library. This was resolved by placing a native library(dll) file together with jar.

    ReplyDelete
  28. @Rineez, @ Anonymous and @Bhaskara , Thanks for your comments guys and good to know that you like Java NoClassDefFoundError tutorial. you may also like How Substring works in Java

    ReplyDelete
  29. I'm using Spring 3 and eclipse.
    My web application worked perfectly, but after making a new compile with maven, I obtain a NoClassDefFoundError.
    I check my classpath and nothig wrong !!

    ReplyDelete
  30. @Anonymous, with Maven this NoClassDefFoundError can be tricky because maven download dependency in your machine, check out the folder where maven downloads jars and see if that Class exists there.

    ReplyDelete
  31. i am getting while trying to run emca (oracle). I am not java developer but as far as i can see env variables are set correctly

    bolbaan1: /usr1/app/oracle/product/10.2.0/bin>emca
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/sysman/assistants/util/sqlEngine/SQLFatalErrorException

    ReplyDelete
  32. Thank you. This helped me a lot.

    Environment was RHEL 5

    The issue in my jar file was that classpath was not being picked up when declared in shell file. I added required class path to ant build file that inturn added it to manifest.mf. That worked.

    ReplyDelete
  33. Hi everybody, I have this problem ONLY with Eclipse: if I try to compile by terminal this is all right.
    The whole error that Eclipse manifet is:

    Exception in thread "main" java.lang.NoClassDefFoundError:
    Caused by: java.lang.ClassNotFoundException:
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

    Please, give me a hand!

    ReplyDelete
  34. Hi tita, you probably need to paste root cause for which clas is throwing java.lang.ClassNotFoundException ? or may be context what you are doing. I m sure there would be some thing which tells during for which particular class its showing this error.

    ReplyDelete
  35. Just thought I'd share that it's also worth checking permissions on the class libraries your application is loading. Incorrect user permissions (for instance root owning a library that should be owned by appuser) could lead to a java.lang.NoClassDefFoundError.

    Recently I went through this. My application was failing with :

    java.lang.NoClassDefFoundError: com/class/failedclass

    The application runs as appuser and imports failedlcass from the class-loader.jar library located: /usr/local/myapp/lib/class-loader.jar

    After making sure the library existed in the correct place I started the application with strace attached which led me to the problem :

    400 17:04:57.674531 open("/usr/local/myapp/lib/class-loader.jar", O_RDONLY) = -1 EACCES (Permission denied)

    Checking permissions on /usr/local/myapp/lib/class-loader.jar showed that it was incorrectly owned by root. Changing the owner back to appuser resolved the issue.

    ReplyDelete
  36. @"its'me" you definitely got a good point and its worth remembering permissions on jar files to avoid java.lang.NoClasDefFoundError. Thanks for your comment.

    ReplyDelete
  37. I am facing the NoClassDefFoundError in my Android app together with the ClassNotFoundError. The app's architecture is that I have a free and a pro version that both are using the same library project.
    The .classpath file has the entry (among other things):
    "kind='con' path='com.android.ide.eclipse.adt.LIBRARIES'"
    and the Android manifest mentiones the activity explicitly. Am i supposed to add the library project's jar explicitly to the classpath? What am I missing here?

    ReplyDelete
  38. hii..
    I have a problem with NoClassDefFoundError this is the error:
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSearchSupport' defined in class path resource [applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: com/trg/search/ISearch
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    can You help me to analyst this error :D
    thanks before

    ReplyDelete
  39. Hi,
    I am facing a problem with NoClassDefFoundError as below. please help me out.
    ------------------------------------------------
    java.rmi.ServerError: Error occurred in server thread; nested exception is:
    java.lang.NoClassDefFoundError: Could not initialize class com.hp.apps.nuncas.server.facade.RMINUNCASFacade_Stub
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:333)
    at sun.rmi.transport.Transport$1.run(Transport.java:159)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
    at com.compaq.libs.temip.applicationinterface.RemoteSession_Stub.getFacade(Unknown Source)
    at com.hp.apps.nuncas.client.base.SessionClient.e(SourceFile:154)
    at com.hp.apps.nuncas.client.base.SessionClient.a(SourceFile:54)
    at com.hp.apps.nuncas.client.base.SessionClient.b(SourceFile:74)
    at com.hp.apps.nuncas.client.base.SessionClient.main(SourceFile:179)
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.hp.apps.nuncas.server.facade.RMINUNCASFacade_Stub
    -----------------------------------------------Note : But RMINUNCASFacade_Stub.class exists under com.hp.apps.nuncas.server.facade.

    ReplyDelete
  40. hi, i created some java files when i run them using netbeans or eclipse they works well. but when i try to run using command prompt i am getting some errors. i am using mysql connector jar files. i have placed all my java files and mysql connector jar in jdk/bin folder. and i hve set my claaspath to jdk/bin folder. i get errors like

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at Dbconnection.Dbconnect(Dbconnection.java:29)
    at fileoperation.parsefiles(fileoperation.java:63)
    at fileoperation.main(fileoperation.java:127)


    if possible will you please mail me your suggestion . i am a student developing a web application . i ahve my project demo day after tmrw i got stuck there. will anybody help me???
    my mail id is adeshbora@gmail.com

    ReplyDelete
  41. Hi adesh, is that coming from Applet, it looks to me as security policy issue, providing your Applet necessary permission may help.

    ReplyDelete
  42. Hello Javin,

    sir we created one batch file parse.bat. we put all source files in C:\Program Files\Java\jdk1.6.0\bin folder that is all java files. and we also put mysql connector in that folder. but when we run that batch file we get errors like

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at Dbconnection.Dbconnect(Dbconnection.java:29)
    at fileoperation.parsefiles(fileoperation.java:63)
    at fileoperation.main(fileoperation.java:127)

    i guess it is the error of classpath. we included that mysql connector jar file in jdk/bin folder and we have set class path to
    classpath=C:\Program Files\Java\jdk1.6.0\bin

    we have gone through some pdf and documents that we googled related to setting up classpath. we also posted our problems on stackoverflow . we have bloged our problem on some blogpost also. we searched a lot over the net. but no positive outcome. we got stuck there. we need your help sir.

    ReplyDelete
  43. Hi Adesh, you don't need to put your code bin folder that's not a proper place you can put your source file anywhere and just need to set your path and classpath properly. run your program with -cp . e.g. java -cp . Helloworld.

    read more about this kind on issues on my post
    How Classpath works in Java
    How to Set PATH for Java in Windows

    ReplyDelete
  44. Hi,

    I have posted 1 issue in Jan-05. Could you help me out to resolve on the same.

    ReplyDelete
  45. Hi Ashwin, your error looks related to RMI , have you implemented Remote Interfaces properly, if you put some context than it would be easy to solve.

    ReplyDelete
  46. if i palced all my source files and my sql connector E:\marketpoint\src\java\com\das\dbmodule so what can be my class path . i included all my source file in com.das.dbmodule package . is it okay to run from command prompt to include package statement or should i remove it .. can i get ur mail id so that i can mail u easily

    ReplyDelete
  47. Hi Javin,
    Thanks for the reply. Actually. we are migrating our application from JDK 1.4 to JDK 1.6 on HP-UX. what we did is, we compiled all java sources of our application through 1.6 compiler and made jar from it and using the same.Actually, I am getting error when try to create instance of my application through other jar file just to establish connection from client to server using, Class name = class.forname(class nmae); Object obj = name.newInstance();
    I debugged the same, It is throwing above exception while execuing name.newInstance(); statement.But it is loading the class through class.forname properly. i still confuse y it is not happening for 1.6!!. I am not sure where I am doing wrong.

    ReplyDelete
  48. Hi Javin,
    I am facing this problem in netbeansIDE please help me.....


    Exception in thread "Thread-0" java.lang.NoClassDefFoundError: modbus/PollToSlave
    at modbus.SimpleThread.run(SimpleThread.java:21)
    Caused by: java.lang.ClassNotFoundException: modbus.PollToSlave
    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:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 1 more
    BUILD SUCCESSFUL (total time: 0 seconds)

    ReplyDelete
  49. Hi, I am facing the following problem:

    1) Uncaught Exception:java.lang.NoClassDefFoundError

    2) on BlackBerry.

    Anyone has found a resolution? Please respond.

    Many thanks,

    ReplyDelete
  50. Hey! I'm so glad I found this blog! I'm struggling with the same issue NoClassDefFoundError with javax.microedition.io.PushRegistry, and I was pissed off when I checked the API and saw that the class was defined... then I checked the my machine to be sure that the PushRegistry.class was included in the JME SDK 3.0 directory bundled with the Netbeans, low and behold it was there! So WTF right? I still don't know how to resolve the issue so I'm hoping someone in this discussion might help me out. If you can just post a comment @RRH Thanks!

    ReplyDelete
  51. @RRH, I agree NoClassDefFoundError are like that frustrating. try steps mentioning here or even ascertain that for which class its not able to find. check classpath, clue is always there.

    ReplyDelete
  52. hi,i am facing the following problem
    the program compiles well in the terminal
    but can't load the applet and it showing

    java.lang.NoClassDefFoundError: SnakeAndLadderApplet (wrong name: assign1/SnakeAndLadderApplet)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:197)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:146)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:608)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:798)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:727)
    at sun.applet.AppletPanel.run(AppletPanel.java:380)
    at java.lang.Thread.run(Thread.java:679)
    please someone help.....

    ReplyDelete
  53. Apologies for posting it without formatting, I really don't know how to. Your help would be appreciated. I tried the things mentioned in the post; Can anybody help?

    02-06 23:49:01.595: E/AndroidRuntime(353): FATAL EXCEPTION: main
    02-06 23:49:01.595: E/AndroidRuntime(353): java.lang.NoClassDefFoundError: javax.microedition.io.Connector
    02-06 23:49:01.595: E/AndroidRuntime(353): at org.ksoap2.transport.ServiceConnectionMidp.(Unknown Source)
    02-06 23:49:01.595: E/AndroidRuntime(353): at org.ksoap2.transport.HttpTransport.getServiceConnection(Unknown Source)
    02-06 23:49:01.595: E/AndroidRuntime(353): at org.ksoap2.transport.HttpTransport.call(Unknown Source)
    02-06 23:49:01.595: E/AndroidRuntime(353): at com.khosla.nisc.Main.doLogin(Main.java:93)
    02-06 23:49:01.595: E/AndroidRuntime(353): at com.khosla.nisc.Main$1.onClick(Main.java:65)
    02-06 23:49:01.595: E/AndroidRuntime(353): at android.view.View.performClick(View.java:2485)
    02-06 23:49:01.595: E/AndroidRuntime(353): at android.view.View$PerformClick.run(View.java:9080)
    02-06 23:49:01.595: E/AndroidRuntime(353): at android.os.Handler.handleCallback(Handler.java:587)
    02-06 23:49:01.595: E/AndroidRuntime(353): at android.os.Handler.dispatchMessage(Handler.java:92)
    02-06 23:49:01.595: E/AndroidRuntime(353): at android.os.Looper.loop(Looper.java:123)
    02-06 23:49:01.595: E/AndroidRuntime(353): at android.app.ActivityThread.main(ActivityThread.java:3683)
    02-06 23:49:01.595: E/AndroidRuntime(353): at java.lang.reflect.Method.invokeNative(Native Method)
    02-06 23:49:01.595: E/AndroidRuntime(353): at java.lang.reflect.Method.invoke(Method.java:507)
    02-06 23:49:01.595: E/AndroidRuntime(353): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    02-06 23:49:01.595: E/AndroidRuntime(353): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    02-06 23:49:01.595: E/AndroidRuntime(353): at dalvik.system.NativeStart.main(Native Method)

    ReplyDelete
  54. When you have the probleme with "exception in threat class no found" when you use cmd(comand prompt) use the command bellow:
    set classpath=%classpath%;.;
    Before running the FileName.class

    C Mihai

    ReplyDelete
  55. @DMC Mihai, Thanks for your comment. you highlighted an important point of including current directory in classpath, I rather add that on before %classpath% e.g.

    set classpath=.;%classpath%;

    ReplyDelete
  56. Exception in thread "main" java.lang.NoClassDefFoundError: KariTest (wrong nam
    karitest/KariTest)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

    ReplyDelete
  57. I copied this from my error message box. I put xxxxx's where my name goes.

    Last login: Tue Feb 14 12:02:46 on console
    port77:xxxxxxx Java version
    Exception in thread "main" java.lang.NoClassDefFoundError: version
    Caused by: java.lang.ClassNotFoundException: version
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    port77: xxxxxxxx

    ReplyDelete
  58. Hi, I'm not a programmer just a regular user of an iMAC. I have application I use to download data from a console that records my exercise work out, e.g. distance, time, KJ, HR, power etc. When I attach my console via a USB cable, the error message I receive is "no supported devices were found". However the detail error message reads as per below.

    java.lang.NoClassDefFoundError: Could not initialize class com.cycleops.d2xx.D2xx
    at com.cycleops.jpowertap.Manager.getConnectedDevices(Manager.java:218)
    at com.cycleops.devicemanager.DeviceManager.getSelectedDevice(DeviceManager.java:139)
    at com.cycleops.devicemanager.DeviceManager.getSelectedDevice(DeviceManager.java:80)
    at com.cycleops.devicemanager.DeviceManager.getSelectedDevice(DeviceManager.java:71)
    at com.cycleops.devicemanager.DownloadDeviceAction.performAction(DownloadDeviceAction.java:65)


    Does anyone know from looking at below, if the issue lies within the app it self or JAVA, as both were download as updates from the respective sites, i.e. JAVA from Apple site and PowerAgent from cyclops site, i.e. I just select the install button and do nothing else, In each case the updates indicate as "successful installation".

    ReplyDelete
  59. @Anonymous, looks like issue with App configuration which requires some settings to be enabled and may not be enable in your Device,though just a guess. I would suggest contacting there support or looking on there installation guide for any pointers (e.g. any settings), shouldn't be issue with Java.

    ReplyDelete
  60. Great post Javin on this common error. I'm glad to see what you spent some time understand this problem at a deeper level. Your Blog has quite a lot of Java tutorials and problem patterns; great sharing for the Java community.

    I would like to add that in my Java EE experience, the typical root cause of NoClassDefFoundError that I see from my clients Java EE apps are either classpath / libraries conflict or code failure of a static{} block. For people interested, I also have a post from my Blog on the NoClassDefFoundError problem patterns from a Java EE perspective along with a sample Java program simulation.

    Thanks again.
    P-H

    ReplyDelete
  61. Hello Iam getting the following error when im compiling a junit testing program
    F:\junit4.10>javac check4PrimeTest.java
    check4PrimeTest.java:4: cannot find symbol
    symbol : class check4Prime
    location: class check4PrimeTest
    private check4Prime check4prime=new check4Prime();
    ^
    check4PrimeTest.java:4: cannot find symbol
    symbol : class check4Prime
    location: class check4PrimeTest
    private check4Prime check4prime=new check4Prime();
    ^
    2 error

    Any one help me to resolve the error

    ReplyDelete
  62. hello im using junit testing tool. Iam having two program check4Prime and check4PrimeTest.java

    When I compiled the first program everything was okay but i getting the following pgm when i compiled the second program

    F:\junit4.10>javac check4PrimeTest.java
    check4PrimeTest.java:4: cannot find symbol
    symbol : class check4Prime
    location: class check4PrimeTest
    private check4Prime check4prime=new check4Prime();
    ^
    check4PrimeTest.java:4: cannot find symbol
    symbol : class check4Prime
    location: class check4PrimeTest
    private check4Prime check4prime=new check4Prime();
    ^
    2 error

    ReplyDelete
  63. Got both exceptions....java.lang.NoClassDefFoundError and java.lang.ClassNotFoundException

    not sure what's that I'm missing here...Any help is highly appreciated.

    Exception in thread "main" java.lang.NoClassDefFoundError: org.eclipse.core.runtime.CoreException
    at java.lang.J9VMInternals.verifyImpl(Native Method)
    at java.lang.J9VMInternals.verify(J9VMInternals.java:69)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:131)
    at com.ibm.ws.webservices.multiprotocol.discovery.ServiceProviderManager.getDiscoveredServiceProviders(ServiceProviderManager.java:378)
    at com.ibm.ws.webservices.multiprotocol.discovery.ServiceProviderManager.getAllServiceProviders(ServiceProviderManager.java:214)
    at com.ibm.ws.webservices.multiprotocol.discovery.ServiceProviderManager.getExtensionRegistry(ServiceProviderManager.java:329)
    at com.ibm.ws.webservices.multiprotocol.discovery.ServiceProviderManager.getWSDLFactory(ServiceProviderManager.java:311)
    at com.ibm.ws.webservices.multiprotocol.AgnosticServiceFactory.getDefinitionFromURL(AgnosticServiceFactory.java:496)
    at com.ibm.ws.webservices.multiprotocol.AgnosticServiceFactory.createService(AgnosticServiceFactory.java:164)
    at sf.application.automation.ws.client.Tempclient.testWebservice1(Tempclient.java:73)
    at sf.application.automation.ws.client.Tempclient.main(Tempclient.java:228)
    Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:639)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:605)
    ... 11 more

    ReplyDelete
  64. Hello, I am trying to run a sample code of speech to text conversion using sphinx4-beta v4.0 but i am getting this error:

    java.lang.NoClassDefFoundError: com/joy/speechtotext/HelloWorld
    Caused by: java.lang.ClassNotFoundException: com.joy.speechtotext.HelloWorld
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)

    pls. help. thanks.

    ReplyDelete
  65. I got this error when I renamed a class, which in turn couldn't be read as it doesn't get updated in the build. Clean and build your project and a new jar will be created. Problem solved.

    ReplyDelete
  66. Hi I was wondering if you could help with this java error:

    Exception in thread "main" java.lang.NoClassDefFoundError: grui/GUI
    Caused by: java.lang.ClassNotFoundException: grui.GUI
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    logout

    Thanks!

    ReplyDelete
  67. Hi Anonymous, problamtic class is grui.GUI, now exact reason could be anything but this class is not available, try suggestion mentioned here like class may not be in classpath.

    ReplyDelete
  68. Hi Jarvin,

    Class files are there, but I am on Mac OS 10.7. I think I have installed the Mac Java update, but still no luck.

    ReplyDelete
  69. Hi Jarvin,

    I think there is a more fundamental problem. I have just tried to compile the .java file and it claims that it cannot find packages, even though the packages are there in same directory! I have tried also setting the classpath and the sourcepath.

    If you have any further insight that would be gratefully appreciated.

    ReplyDelete
  70. do you have typo here grui/GUI is it "grui" or "gui" ?

    ReplyDelete
  71. HELP
    i am making a mod for this game minecraft(www.minecraft.net) and i am working on a plugin mod. when i load the plugins on eclipse it works just fine and if i have no plugins it works fine but when i try to start it outside of eclipse i get this


    error:java.lang.NoClassDefFoundError: org/Command
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    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:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at org.PluginManager.LoadPlugins(PluginManager.java:48)
    at mod_spchat.load(mod_spchat.java:38)
    at ModLoader.init(ModLoader.java:877)
    at ModLoader.addAllRenderers(ModLoader.java:186)
    at aho.(aho.java:79)
    at aho.(aho.java:9)
    at net.minecraft.client.Minecraft.a(Minecraft.java:423)
    at net.minecraft.client.Minecraft.run(Minecraft.java:784)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.ClassNotFoundException: org.Command
    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:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 20 more

    ReplyDelete
  72. Hi everyone:
    When you have this kind of problem you have to be sure that all the jars are added in the main project's build path. I had this error and I was freaking out :P I had a jar file that I was using in a project (main project) but this jar file was using another jar file. That last jar file was the problem. It wasn't in the build path of the main project. The problem was solved when I added it in the main project's build path.

    Good luck guys :D

    ReplyDelete
  73. After running long (days) & memory intensive process (tens of full GDs), I was receiving NoClassDefFound Error.

    The "cause" was running with '-jar' parameter. Unpacking the .jar file & running java.exe without '-jar' parameter solved the problem.

    Win7 & Win2008; 64b java 1.6u24 and j.6u30

    ReplyDelete
  74. Hi, I'm getting a NoClassDefFoundError with the following error:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lo
    gging/LogFactory
    at org.apache.commons.httpclient.HttpMethodBase.(HttpMethodBase.
    java:104)
    at com.hyperion.bpma.utilities.WebUtilities.postAction(WebUtilities.java
    :64)
    at com.hyperion.bpma.actions.SessionActions.getSSOToken(SessionActions.j
    ava:150)
    at com.hyperion.bpma.actions.SessionActions.Login(SessionActions.java:53
    )
    at com.hyperion.bpma.commands.CommandProcessor.processCommand(CommandPro
    cessor.java:111)
    at com.hyperion.bpma.cli.BPMAPlus.processCommand(BPMAPlus.java:404)
    at com.hyperion.bpma.cli.BPMAPlus.executeScript(BPMAPlus.java:196)
    at com.hyperion.bpma.cli.BPMAPlus.main(BPMAPlus.java:91)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFacto
    ry
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    ... 8 more

    Do you see anything obvious here? I do have Java_Home in the classpath.

    ReplyDelete
  75. I see a number of us this error: this seems to be caused when I tried to rename a class, no idea how to correct it.

    SEVERE: Error configuring application listener of class com.paul.listener.HibernateListener
    java.lang.NoClassDefFoundError: com/paul/listener/HibernateListener (wrong name: com/mkyong/listener/HibernateListener)

    ReplyDelete
  76. I had the same problem running a netbeans project from the cmd to use redirection to get some input.

    I was using the following command:
    ...\src> java [package].[class].java < input.txt

    It worked fine when I removed the .java extension like so:
    ...\src> java [package].[class] < input.txt

    ReplyDelete
  77. Terminate CLASSPATH with ';' as it could be one of the reasons.
    Example (cgwin):
    export CLASSPATH="foo.jar;bar.jar;"
    (use set instead of export in cmd prompt)

    ReplyDelete
  78. java.lang.NoClassDefFoundError: HelloWorld
    Caused by: java.lang.ClassNotFoundException: HelloWorld
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Exception in thread "main"

    This is an error that happens to me when I try to run a simple hello world, and many other classes, could anyone help me?

    ReplyDelete
  79. try running HelloWorld with -classpath . option from the same directory where you have HelloWorld class file.

    ReplyDelete
  80. i am having the same kind of problem when running jdbc with servlet......the error msg is...

    java.lang.NoClassDefFoundError: students
    Caused by: java.lang.ClassNotFoundException: HelloWorld
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClass Internal(ClassLoader.java:320
    Exception in thread "main"
    plz..tel a solution to this ....

    ReplyDelete
  81. When I moved some junit test classes from one package 2 another for testing purposes, Eclipse forgot where they were. I simply saved the class, then deleted it from eclipse and then rebuilt it. It worked!

    ReplyDelete
  82. Desperately Seeking Help!!
    I paid and downloaded a program from online which was 100% guaranteed with a 30 day moneyback guarantee, well thats a joke...what liars...this is what they have posted Q) I get an error message when I install it on my BlackBerry. What could have gone wrong?

    A) If after transferring the files (which initiates all the actions given in its menu) it does not run or you get any error screen, for example “Uncaught Exception: Java.Lang.NoclassDeffound Error” or “error 907 invalid jar” then there has been some error in transferring the files correctly to your cell phone.

    It won't be possible for us to pin-point exactly what has caused this without actually seeing the details.

    There could be various causes for your files not getting transferred depending on your computer configuration.

    There is a strong possibility that a pop-up blocker, your firewall settings, your spyware or anti-virus program or any similar app. is coming in the way of installation.

    In this case you will have to let your computer engineer take a look at your computer settings and get the software transferred properly.

    The name of the program is Cell-Spy_Brand_New_2011, they also guarateed it was guaranteed to work on almost any cell phone.
    I can give you the name of the files I don't know what else to do or how to do it...so sorry.

    Blooover2.jar Executable Jar File, Blooover2b.jar, bluesniff-0.1.tar.tar, BTExplorer.jar, and btscanner-2.0.tar.tar.

    I get the application successfully installed on my phone, but when I try to run it, I get
    Uncaught Exception:java.lang.NoClassDefFoundError.
    Honestly I have been going almost 48 hrs straight trying to find a solution, any help at all would be so appreciated, and thanks so much.

    ReplyDelete
  83. Hi Javin,
    i'm getting the following error:

    java.lang.NoClassDefFoundError: org/vivoweb/harvester/util/DatabaseClone
    Caused by: java.lang.ClassNotFoundException: org.vivoweb.harvester.util.DatabaseClone
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: org.vivoweb.harvester.util.DatabaseClone. Program will exit.
    Exception in thread "main"

    when i'm trying to execute jar file from .sh file. i'm tring to run that shell file through cygwin in windows, but it throws the above exception.
    don't know where the main problem is??is it related to library jar files that are being used by jar file i wanna execute???
    what i understand is that i'm not setting right classpath.
    can you please give me any suggestion???

    ReplyDelete
  84. When I run my program in Linux i get the following error, any idea / suggestion? Thanks

    Exception in thread "main" java.lang.NoClassDefFoundError
    at java.awt.Event.(Event.java:581)
    at jet.controls.JetProperty.propertyChanged(jet/controls/JetProperty)
    at jet.controls.JetNumber.set(jet/controls/JetNumber)
    at jet.universe.JetUUniverse.(jet/universe/JetUUniverse)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
    at java.lang.Class.newInstance0(Class.java:350)
    at java.lang.Class.newInstance(Class.java:303)
    at jet.jetc.JetCReader.$9cc(jet/jetc/JetCReader)
    at jet.jetc.JetCReader.read(jet/jetc/JetCReader)
    at jet.jetc.JetCReader.read(jet/jetc/JetCReader)
    at jet.jetc.ReportLoader.loadObject(jet/jetc/ReportLoader)
    at jet.jetc.ReportLoader.loadObject(jet/jetc/ReportLoader)
    at jet.jetc.ReportLoader.load(jet/jetc/ReportLoader)
    at jet.universe.JetUUniverse.$g3c(jet/universe/JetUUniverse)
    at jet.universe.JetUUniverse.LoadUniverse(jet/universe/JetUUniverse)
    at jet.universe.JetUUniverse.LoadUniverse(jet/universe/JetUUniverse)
    at jet.bean.JRCatalog.loadCatalog(jet/bean/JRCatalog)

    ReplyDelete
  85. hi..i m also getting the following error but not able to resolve..kindly help..

    org.eclipse.core.runtime - org.eclipse.core.jobs - 2 - An internal error occurred during: "MBOM_PanelAction 0".
    java.lang.NoClassDefFoundError: com/teamcenter/rac/cme/mpp/MPPApplication
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructors(Unknown Source)
    at com.teamcenter.rac.util.Instancer.newInstanceEx(Unknown Source)
    at com.teamcenter.rac.util.Registry.newInstanceForEx(Unknown Source)
    at com.teamcenter.rac.util.Registry.newInstanceFor(Unknown Source)
    at com.mvml.rac.cme.actions.MBOM_PanelAction.run(MBOM_PanelAction.java:56)
    at com.teamcenter.rac.aif.common.actions.AbstractAIFAction$1.run(Unknown Source)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

    ReplyDelete
  86. Hi,

    I changed my compiler compliance level to 1.4 from 1.7.
    I program was running with out any errors in 1.7, but after changing to 1.4 it gives me below error.

    java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group
    at mpc.necspec.ui.NecSpecUIMain.main(NecSpecUIMain.java:14)
    Exception in thread "main"

    Can anyone suggest me what to add in class path?

    ReplyDelete
  87. Can anybody help me to resolve the following error:


    Exception in thread "pipeline-1" java.lang.OutOfMemoryError
    Exception in thread "pipeline-4" java/lang/NoClassDefFoundError: com/ibm/oti/util/Msg
    at java/lang/ThreadGroup.uncaughtException (ThreadGroup.java:772)
    at java/lang/ThreadGroup.uncaughtException (ThreadGroup.java:766)
    at java/lang/ThreadGroup.uncaughtException (ThreadGroup.java:766)
    at java/lang/Thread.uncaughtException (Thread.java:1210)
    java/lang/OutOfMemoryError
    at java/lang/Throwable.printStackTrace (Throwable.java:363)
    at java/lang/Throwable.printStackTrace (Throwable.java:212)
    at java/lang/Throwable.printStackTrace (Throwable.java:163)

    ReplyDelete
  88. compiled with sun jdk but run with bea jdk may also throw NoClassDefFoundError

    ReplyDelete
  89. A very important point for all xml document.......

    I think most problem of XML can be solved, especially when you think that everything I coded is fine........and the output is not that one as I think.

    If you write java code with any IDE, when u run a file, it will be saved and compiled by default......

    But for XML files, every times you modified it, you have to Build it to get the correct answer........

    Build the Project and have a useful time.....

    ReplyDelete
  90. Hi, I also meet the same situation today. I could run it successfully this morning, but after including some jquery script in one of my jsp files, it throws the following error information. After I deleting all the modifications I have made, it still has the following error information. Please help me. Thanks

    SEVERE: Servlet.service() for servlet [AdminAuth] in context with path [/PowerConsumption] threw exception [Servlet execution threw an exception] with root cause
    java.lang.NoClassDefFoundError: src/Config
    at src.AdminAuth.service(AdminAuth.java:39)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    ReplyDelete
  91. I'm trying to deploy a struts1 application (compiled with java6) on tomcat 5.0.25 & java 1.6.0_24 in a SOLARIS machine. I get the following error when i'm trying to access the home page

    javax.servlet.ServletException: javax/servlet/jsp/tagext/TagExtraInfo
    java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagExtraInfo

    However the same application (without any changes) works fine in tomcat5.0.25 & java 1.6.0_21,java 1.5.0_20 (when compiled with java5) in SOLARIS expand »& on tomcat5.0.25 & java 1.6.0 on AIX.

    Since the tomcat version is the same throught the different deployments i belive i need not check if there are multiple jars (in my application & in tomcat) containing the class javax.servlet.jsp.tagext.TagExtraInfo.

    Also i checked in the JAVA_HOME/jre/lib & JAVA_HOME/jre/lib/ext folders to check if there are jars containing the class.I couldn't find any.

    ReplyDelete
  92. hi,
    I am trying to invoke a method in class remotely.and I am getting
    java.rmi.ServerError: Server exception; nested exception is:
    java.lang.NoClassDefFoundError
    It does not come consistently by that I mean most of the times I am able to invoke that method and process goes through but once in a while it crashes with that error. What can cause this inconsistent behavior
    thanks

    ReplyDelete
  93. Another common issue (not sure if this has been mentioned in the comments,there are 95+ and I'm not going to read them all), is that your .java file is written within a package, so when you compile it into a .class file, and for example a JApplet tries to render it on a website, it is no longer in the package so it won't render properly. This was an issue for me. Hopefully this helps someone :)

    ReplyDelete
  94. Hi I am getting an error message "Exception in thread "main" java.lang.NoClassDefFoundError :TestMain"

    My classpath is set to C:\Program Files\Java\jre1.6.0\lib
    and my TestMain.java is under "C:\Users\ACER\Documents". I tried to paste the TestMain.java in Java folder under Program Files but syill i m getting the same error. Please help me

    ReplyDelete
  95. Hi Javin,

    I'm planning to consolidate and share common NoClassDefFoundError problem cases I have worked on last month for an IT client. I have part #1 available java.lang.NoClassDefFoundError: How to resolve and I’m hoping this will be a good complement to your great article on the subject. A good understanding of Java Classloaders is key to understand this problem in Java EE world so extra focus will be put on that.

    I also want to add that your Blog has been a good inspiration for me to start writing and sharing on Java related problem patterns and I thank you for that.

    Thanks.
    P-H

    ReplyDelete
  96. Hello Javin

    Thank you very much for you post. I am getting this error for a simple thing which I am doing...

    I installed jdk1.6.0_33 at 'C:\Program Files\Java\jdk1.6.0_33' in my system and I have jre6 at 'C:\Program Files (x86)\Java\jre6'. My path envrionment variable has ' C:\Program Files\Java\jdk1.6.0_33\bin' and classpath variable has 'C:\Program Files\Java\jdk1.6.0_33\lib'.

    Now I just run javac from my command prompt in my Windows 7 system and I get -

    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/java
    ain
    Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: com.sun.tools.javac.Main. Program will exit.


    Can you please guide me to solve this problem, I have already spent trying different configurations with my path, classpath variables. And I have also reinstalled it many times. But I still get this error.

    Thanks again
    Sam

    ReplyDelete
  97. Hi,

    Nice blog! Is there an email address I can contact you in private?

    ReplyDelete
  98. I solved my problem. I reinstalled the Jre6 and jdk1.6.0_25 in the same Java Folder (i.e. C:\Program Files\Java). And set my path to
    "C:\Program Files\Java\jdk1.6.0_25\bin;C:\Program Files\Java\jre6\bin;C:\.;"

    and JAVA_HOME to "C:\Program Files\Java\jdk1.6.0_25". I removed the classpath variable.

    And my 'javac' command works. I think one of the reasons my javac command didn't work may be that:
    (i) My jdk and jre were in different folders. Now, I kept them in single folders.
    (ii) I reinstalled checking the ocrrect versions.

    Any one of the reason might ahve solved the problem.

    Thank You for your help guys.
    Sam

    ReplyDelete
  99. @Nikos, Thanks. you can reach me at savingfunda@gmail.com

    ReplyDelete
  100. @Sam, Glad you hear that you got your Java environment setup properly. looks like re installation of Java, set Java PATH variable properly.

    ReplyDelete
  101. Hello, we are getting "Exception in thread "main" java.lang.NoClassDefFoundError: com/ximpleware/VTDGen", Its Java project with maven and vtd-xml is included in maven dependency. Please help with this NoClassDefFoundError.

    ReplyDelete
  102. Thanks for this article,
    a quick comment is java.lang.NoClassDefFoundError could also happen when your class fails while loading at runtime, for example you have a class with a static block which does some initialization work. so if static block throws any runtimeException then caller class will get the java.lang.NoClassDefFoundError exception.

    ReplyDelete
  103. Hi,
    I am developing a plugin to create/compile/run a CDT project using Eclipse. I am using CCorePlugin.getDefault().createCProject() api in my program.
    When I try to install my plugin and run, it gives the below error.
    java.lang.NoClassDefFoundError: org/eclipse/cdt/core/CCorePlugin
    at sourceanalysistoolplugin.wizards.CDTProjectManager.createCDTProj(CDTProjectManager.java:43)
    at sourceanalysistoolplugin.intermediate.SourceCompileManager.createProject(SourceCompileManager.java:38)
    at sourceanalysistoolplugin.actions.SATMenuCompileActionDelegate.run(SATMenuCompileActionDelegate.java:63)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
    at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    Caused by: java.lang.ClassNotFoundException: org.eclipse.cdt.core.CCorePlugin
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 32 more


    I have added org.eclipse.cdt.core jar file in plugin dependencies.
    Could you please guide me to solve the problem.

    ReplyDelete
  104. Hey thank you very very very very very much for your help, you´ve got no idea how much you've just helped me... This information about exceptions is more than worth. Thank you!!!!!!

    ReplyDelete
  105. I am trying to deploy me app in weblogic and I get this error while starting the server. The expected jar is present in the app/WEB-INF/lib folder.

    The exception it throws is :

    Jul 24, 2012 9:54:26 AM IST>

    ReplyDelete
  106. Exception in thread "main" java.lang.NoClassDefFoundError:
    Caused by: java.lang.ClassNotFoundException: com.su.STSQLEditor
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Could not find the main class: com.su.STSQLEditor. Program will exit.

    ReplyDelete
  107. I got this error by compiling a class and then calling the class itself using java. For example:

    javac MyClass.java
    java MyClass.class
    # Error here
    java MyClass
    # Everything is beautiful

    It totally a raw beginner mistake, but I am a raw beginner, so there we go. :-)

    ReplyDelete
  108. Hi
    I am facing this type of problem at the time of when we execute our selenium script from ant command...

    java.lang.NoClassDefFoundError: org/mozilla/javascript/tools/shell/Main Exception in thread "main"

    Please find the solution and resolve my problem...
    Thanks in advance...

    ReplyDelete
  109. Hi
    I am getting the follwoing error
    Exception in thread "main" java.lang.NoClassDefFoundError: com/amdocs/pc/backend/aspects/SessionContextLoaderInterceptor
    at com.amdocs.pc.backend.utils.EPCSessionContextProvider.get(EPCSessionContextProvider.java:20)
    at com.amdocs.pc.backend.utils.EPCSessionContextProvider.getUserName(EPCSessionContextProvider.java:25)
    at com.amdocs.pc.backend.aspects.LoggerAspect.log(LoggerAspect.java:22)
    at org.slf4j.impl.EpcLogger.log(EpcLogger.java:515)
    at org.slf4j.impl.EpcLogger.log(EpcLogger.java:503)
    at org.slf4j.impl.EpcLogger.debug(EpcLogger.java:196)

    Where as the jar for this class is included in the classpath

    ReplyDelete
  110. Using Eclipse IDE . Once I realized that this error may occur during compile time I went to Project->Clean->Select Project you want to clean. What this will do is delete all the compiled files for the selected project and re-compile that project hopefully fixing any error that happened during last compile. Worked for me. Hope this helps

    ReplyDelete
  111. Thanks for sharing your experience Anonymous, Exception in thread "main" java.lang.NoClassDefFoundError has many ways to surface, recently I encounter in a totally different way. I create a tar file using cygwin and extracted on solaris box only to encounter Exception in thread "main" java.lang.NoClassDefFoundError, later I found that many class files has extension .cl or .clas or .cla especially those which have long package hierarchy. after using find command in solaris to find all those files and correcting them, application worked fine.

    ReplyDelete
  112. I am getting the following error:

    Caused by: java.lang.NoClassDefFoundError: Could not initialize class im
    at jk.b(SourceFile:94)
    at com.trapeze.appl.gp2.beans.ServerBean.getLearntSwitches(SourceFile:534)
    at com.trapeze.appl.gp2.beans.ServerBean.getLearntSwitchesExist(SourceFile:548)
    ... 152 more

    jk and im are obfuscated classes that are in the same jar library.
    Can you please give me a hint about a possible root cause?

    Thanks,
    Liviu

    ReplyDelete
  113. Hello ,


    I have used a tutorial from the net using which I have compiled and made an EJB jar and deployed it in standalone folder of jboss as 7.7.1 server.

    I have added a client user name using add user.bat
    I also have a jndi.properties file.

    My client class makes a lookup and when I try to run it, I get the following error :


    Exception in thread "main" java.lang.NoClassDefFoundError: test/Client

    Caused by: java.lang.ClassNotFoundException: test.Client


    The command which shows this error is :


    java -cp JBOSS_HOME/bin/client/jboss-client.jar:. test.Client ejb:/client-ejb//ClientBean!test.ClientIF


    Can youguide me with what the issue is?

    Thanks a lot.

    Appreciate any help.


    Suril

    ReplyDelete
  114. any body can help me to resolve this issue?
    it gets when i start my jboss.

    pls reply @ patel_niket9@yahoo.co.in


    09:59:36,017 WARN [verifier] EJB spec violation:
    Bean : PaymentGatewaySessionBean
    Section: 22.2
    Warning: The Bean Provider must specify the fully-qualified name of the Java class that implements the enterprise bean's business methods in the element.
    Info : Class not found on 'com.session.PaymentGatewaySessionBean': Unexpected error during load of: com.session.PaymentGatewaySessionBean, msg=PermGen space

    ReplyDelete
  115. if you type
    java MyClass.class
    you will get NoClassDefFoundError
    You must type only the file name:
    java MyClass

    ReplyDelete
  116. Hi frndzzz i am facing this error ple help me..i have checked the calss path ..it is correct but still i am facing this issue plzzz help me ASAP :((((((




    ERROR
    ------------------------------------------------
    init:
    deps-module-jar:
    deps-ear-jar:
    deps-jar:
    library-inclusion-in-archive:
    library-inclusion-in-manifest:
    compile:
    compile-test-single:
    run-test-with-main:
    java.lang.NoClassDefFoundError: com\MainApp (wrong name: com/MainApp)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main" Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)

    ReplyDelete
  117. hi all, when I'm using netbeans everything works fine. But the same program gives noclassdeffounderror with cmd. any idea why this is happening?

    ReplyDelete
  118. "Uncaught Exception:java.lang.NoClassDefFoundError" on BlackBerry app.

    Does enyone know the solution?
    Thanks in advance,
    Luke

    ReplyDelete
  119. Thanks for this article. I had the same error with classes in a jar file. Now i copied the jar file to the libs folder and added it to the project. Thank god I am a happier man after 24 hours of confusion

    ReplyDelete
  120. Dont know if it has been mentioned yet, but this was the problem for me. So simple and yet so annoying and hard to find a solution for it on google:

    If your compliance level is higher than the one the server is using, that can also result in a NoClassDefFoundError. e.g. you are using java1.7 in your eclipse and the server is using 1.6.

    ReplyDelete
  121. I am creating a java web application and I am having this problem with the DataBaseHelper class. Here is my code:

    <%
    List computers = ComputerDatabaseHelper.getAllComputers();
    if(computers!=null)
    {
    for(int ix=0; ix computers = ComputerDatabaseHelper.getAllComputers();

    ReplyDelete
  122. I solved it! The problem was with the creating of the data base. So I just changed the data base name in the hibernate file. This worked for me :)

    ReplyDelete
  123. another frustrating case for newbies:

    javac will work with -classpath in any order, but for java, the -classpath argument must come before the class whose main method you are executing.

    ReplyDelete
  124. plz,
    send solution of
    Exception in thread "main" java.lang.NoClassDef
    FoundError: Files\Java\jdk1/6/0_0

    ReplyDelete
  125. does advise given here to solve NoClassDefFoundError also applicable to Android Application development ? Can I use these tips to troubleshoot java.lang.NoClassDefFoundError in Android, please advise.

    ReplyDelete
  126. Hello,
    I am trying to create a bindings file on windows server 2008 to script the MQ using loadrunner. The issue i am facing is that after installing the mq files and jdk on the server when i try to execute the JMSASdmin batch file i get the following error:
    Exception in thread "main"java.lang.NoClassDefFoundError: javax/jmsJMSException
    at java.lang.Class.forName0(NativeMethod)
    at java.lang.Class.forName(UnknownSource)
    at com.ibm.mq.MQEnvironment$2.run(MQEnvironment.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.ibm.mq.MQEnvironment.(MQEnvironment.java:550)
    at com.ibm.mq.jms.services.ConfigEnvironment.(ConfigEnvironment.java:190)
    at com.ibm.mq.jms.admin.JMSAdmin.(JMSAdmin.java:195)
    at com.ibm.mq.jms.admin.JMSAdmin.main(JMSAdmin.java:1832)
    Caused by: java.lang.ClassNotFoundException: javax.jms.JMSException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 8 more

    I have checked my classpath and it has the jms.jar file in it. I have tried reinstalling th mq files and jdk 7 on my machine multiple times but get the same error. I have done the exact same thing on my local desktop and it works fine. If anyone has any suggestions regarding this it would be a life saver.
    Thanks.

    ReplyDelete
  127. I'm getting Exception in thread "main" java.lang.NoClassDefFoundError: while using static inner class

    ReplyDelete
  128. I'm working with MyEclipseWorkbench8.5 when I'm working with simple class files it is working fine but while working with the JDBC it is giving this following exceptionException:

    in thread "main" java.lang.NoClassDefFoundError: java/sql/SQLClientInfoException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:213)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
    at java.sql.DriverManager.getConnection(DriverManager.java:548)
    at java.sql.DriverManager.getConnection(DriverManager.java:180)
    at com.Mytest.ConnectionPool.getConnection(ConnectionPool.java:17)
    at com.Mytest.DBTest.main(DBTest.java:15)

    I have developed my project like this:
    1. I have given perfect database properties.
    2. I have added corresponding jar file in classpath(with the above tutorial I have traced com.mysql.jdbc.Driver class also in the jar and I have attached same jar file to my project classpath)
    3. I have tested this code in some other system and it is working fine.

    Kindly help me to rectify this problem...

    Thanks in advance

    ReplyDelete
  129. Hai friends,
    iam new to java programming.i have studied java in my graduation.
    i want to know about path & class path addresses and why we need path addresses.please,let me know....as soon as possible...

    ReplyDelete
  130. i am getting many error, like:

    Could not find class 'com.gargoylesoftware.htmlunit.html.HtmlForm', referenced from method com.timelystatusupdater.MyLoggedInFragment.publishStory

    and finally i am getting this error:

    FATAL EXCEPTION: main
    java.lang.ExceptionInInitializerError
    at com.timelystatusupdater.MyLoggedInFragment.publishStory(MyLoggedInFragment.java:933)
    at com.timelystatusupdater.MyLoggedInFragment.access$24(MyLoggedInFragment.java:875)
    at com.timelystatusupdater.MyLoggedInFragment$4.onClick(MyLoggedInFragment.java:227)
    at android.view.View.performClick(View.java:4202)
    at android.view.View$PerformClick.run(View.java:17340)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5039)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.NoClassDefFoundError: org.apache.commons.lang3.StringUtils
    at com.gargoylesoftware.htmlunit.util.URLCreator$URLCreatorStandard.toUrlUnsafeClassic(URLCreator.java:66)
    at com.gargoylesoftware.htmlunit.util.UrlUtils.toUrlUnsafe(UrlUtils.java:193)
    at com.gargoylesoftware.htmlunit.util.UrlUtils.toUrlSafe(UrlUtils.java:171)
    at com.gargoylesoftware.htmlunit.WebClient.(WebClient.java:159)
    .. 14 more

    i am trying to use HTMLUNIT in amy android project

    ReplyDelete
  131. Hi...

    Please help me... When I run my test suite I am getting this error.. I tried all ways listed under
    http://code.google.com/p/testng-eclipse/issues/detail?id=43 and nothing worked for me..:( I am not using maven.

    java.lang.NoClassDefFoundError: org.testng.internal.ClassImpl
    at java.lang.Class.initializeClass(libgcj.so.90)
    at org.testng.internal.BaseClassFinder.findOrCreateIClass(BaseClassFinder.java:48)
    at org.testng.internal.TestNGClassFinder.(TestNGClassFinder.java:117)
    at org.testng.TestRunner.initMethods(TestRunner.java:413)
    at org.testng.TestRunner.init(TestRunner.java:235)
    at org.testng.TestRunner.init(TestRunner.java:205)
    at org.testng.TestRunner.(TestRunner.java:160)
    at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:142)
    at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
    at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
    at org.testng.SuiteRunner.init(SuiteRunner.java:157)
    at org.testng.SuiteRunner.(SuiteRunner.java:111)
    at org.testng.TestNG.createSuiteRunner(TestNG.java:1278)
    at org.testng.TestNG.createSuiteRunners(TestNG.java:1265)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1119)
    at org.testng.TestNG.run(TestNG.java:1036)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
    Caused by: java.lang.ClassNotFoundException: com.google.inject.Module not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/afs/.cpiv.com/techhome/shari.dh/.eclipse/org.eclipse.platform_3.5.0_2045279800/plugins/org.testng.eclipse_6.8.0.20121120_1820/lib/testng.jar,file:/afs/.cpiv.com/techhome/shari.dh/workspace/nstest/bin/,file:/afs/.cpiv.com/techhome/shari.dh/Desktop/selenium-server-standalone-2.28.0.jar,file:/afs/.cpiv.com/techhome/shari.dh/Desktop/selenium-java-2.28.0.zip,file:/afs/.cpiv.com/techhome/shari.dh/Desktop/org.testng.eclipse_6.8.0.20121120_1820.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
    at java.net.URLClassLoader.findClass(libgcj.so.90)
    at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
    at java.lang.ClassLoader.loadClass(libgcj.so.90)
    at java.lang.ClassLoader.loadClass(libgcj.so.90)
    at java.lang.Class.initializeClass(libgcj.so.90)
    ...18 more

    Thanks!

    ReplyDelete
  132. Hi, i suppose you are tired of questions on this topic, however, y wish you could check my error. Y have a thread on stackoverflow, on this link (y don't post the full log, i think this way is more confortable for you...): http://stackoverflow.com/questions/15650035/deployment-exception-while-creating-a-webservice-on-java-using-axis2

    ¡thanks!

    ReplyDelete
  133. Hi is there any chance that someone can help me solve this ???

    java.lang.NoClassDefFoundError
    at javax.crypto.Cipher.getInstance([DashoPro-V1.2-120198])
    at coldfusion.compiler.TemplateReader.decrypt(Unknown Source)
    at coldfusion.compiler.TemplateReader.(Unknown Source)
    at coldfusion.compiler.NeoTranslationContext.getPageReader(Unknown Source)
    at coldfusion.compiler.NeoTranslator.translateJava(Unknown Source)
    at coldfusion.compiler.NeoTranslator.translateJava(Unknown Source)
    at coldfusion.runtime.TemplateClassLoader$1.fetch(Unknown Source)
    at coldfusion.util.LruCache.get(Unknown Source)
    at coldfusion.runtime.TemplateClassLoader$TemplateCache.fetchSerial(Unknown Source)
    at coldfusion.util.AbstractCache.fetch(Unknown Source)
    at coldfusion.util.SoftCache.get(Unknown Source)
    at coldfusion.runtime.TemplateClassLoader.findClass(Unknown Source)
    at coldfusion.filter.PathFilter.invoke(Unknown Source)
    at coldfusion.filter.LicenseFilter.invoke(Unknown Source)
    at coldfusion.filter.ExceptionFilter.invoke(Unknown Source)
    at coldfusion.filter.ClientScopePersistenceFilter.invoke(Unknown Source)
    at coldfusion.filter.BrowserFilter.invoke(Unknown Source)
    at coldfusion.filter.GlobalsFilter.invoke(Unknown Source)
    at coldfusion.filter.DatasourceFilter.invoke(Unknown Source)
    at coldfusion.CfmServlet.service(Unknown Source)
    at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
    at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:241)
    at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
    at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:198)
    at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
    at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

    ReplyDelete
  134. I wanted to install MATLAB on FC17_x64. I had a problem with installation but it somehow got installed successfully when i unchecked Aeromodeling toolbox. However, when i run matlab I am getting NoClassDefFoundError:

    Exception in thread "main" java.lang.NoClassDefFoundError: com/mathworks/instwiz/arch/ArchGuiFactory
    Caused by: java.lang.ClassNotFoundException: com.mathworks.instwiz.arch.ArchGuiFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: com.mathworks.activationclient.ActivationApplication. Program will exit.
    =======================================

    how to fix this problem ??

    ReplyDelete
  135. How to fix exception in thread main java.lang.noclassdeffounderror wrong name this problem mate, Can anyone please help here

    ReplyDelete
  136. I'm getting NoClassDefFoundError while running a TestNG test class from a plugin project. It is not able to find the class files to which the target platform is pointing to. Please help.
    Thank you.

    ReplyDelete
  137. I am using a J2EE application with web and ejb modules.It is a struts-hibernate architecture.I have got exceptions like:1)Undefined alias
    2)missingResourceBundle exception:Resource bundle with base name jdbc can't be found.
    All these issues are classloader and classpath related.

    I want to know the order and priorities in which jars will be available in application If its 1)In default webapp/lib directory
    2)loaded by setDomain.env of weblogic
    3)In weblogic-application.xml
    4)In manifest.mf
    Or Called from anywhere..Please guide I am stuck. I have three folders in my project 1)EAR-CONTENT 2)ejb-module 3)webapps.
    I have jar files in application at 1)ear-content/APP-INF/lib 2)webapps/webcontents/webinf/lib

    ReplyDelete
  138. I got this error after using AspectJ with compile time weaving. My class file was invalid because it contained the duplicated methods due to incorrect byte code manipulation.

    ReplyDelete
  139. I have faced the same error java.lang.NoClassDefFoundError in catalina.out when starting tomcat.

    I was trying to find the root cause and to fix the problem and unfortunately it found something very strange thing that I am getting the same error when there are few extra symbol added by mistake to $JAVA_OPTS.

    ReplyDelete
  140. Hi, I'm getting this error from today. The site was working fine for a litte time, I don't made any changes and I'm getting this error today. The host server said me that they didn't change anything, but I'm not getting this error locally, I'm using Ecilpse and Tomcat 6 and everything works fine locally. I read all your post but I'm not sure waht to do, I don't have the error at my computer, only on server side and nothing was changed, I really don't understand, I'm really new in Java Web developpment.
    My error is :
    type Exception report

    message java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.runtime.JspApplicationContextImpl

    description The server encountered an internal error that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.runtime.JspApplicationContextImpl
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:268)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    root cause

    java.lang.NoClassDefFoundError: Could not initialize class org.apache.jasper.runtime.JspApplicationContextImpl
    org.apache.jasper.runtime.JspFactoryImpl.getJspApplicationContext(JspFactoryImpl.java:216)
    org.apache.jsp.redirect_jsp._jspInit(redirect_jsp.java:22)
    org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.36 logs.

    Thanks, Mary

    ReplyDelete
  141. Hello Marie, try restarting Tomcat, there is not much clue about the issue, but looks like problem with one of the JSP page, I would suggest using isolation method to debug e.g. try removing JSP one by one, to find the problematic one.

    ReplyDelete
  142. Thanks, it solved it

    But it's a little unclear and I had a hard time figuring it out.

    My error was due to ExceptionInInitializerError, but I didn't see this in the log. This is because my program executes hundreds of threads calling the culprit class, and only on the first time the ExceptionInInitializerError appears. All subsequent calls just give NoClassDefFoundError, which was what my console was spammed with.

    ReplyDelete
  143. I just wanted to mention that I encountered the NoClassDefFoundError on a project I was working on. The server being setup was using a different version of Java by IBM, rather than Oracle's. On my development machine it worked for me, but on the server I got that error. The issue was resolved once they redid Java using Oracle's version (and Tomcat as well). This may be the solution to someone's problem here as well to consider.

    ReplyDelete
  144. HI While calling WS through Junit i am getting below error, this error only occurs through Junit and not through application (i.e. after deployment on server)
    31-Jul-2013 13:14:41 com.ibm.ws.webservices.engine.WebServicesProperties$2 run
    WARNING: WSWS3227E: Error: Exception:
    java.lang.InstantiationException: javax.xml.parsers.SAXParserFactory
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1300)
    any idea please?

    ReplyDelete
  145. Compilation error: java.lang.NoClassDefFoundError: Lorg/openxmlformats/schemas/spreadsheetml/x2006/main/CTXf;

    ReplyDelete
  146. Hi,

    Can anyone help me with this error found on the log? What's the cause of this issue.

    [435240 http-8223-28(48056)] Event(Code=LOG_STORE_EXCEPTION, id=#18B94I48056P112) occurred at 4/30/13 12:15 PM: com.inquira.infra.gateway.GatewayExceptionDO_NOT_ADDcom.inquira.event
    [435240 http-8223-28 (112)] Gateway encountered error: com.inquira.infra.gateway.GatewayException: [http-8223-28 @ Tue Apr 30 12:15:24 SGT 2013] (GATEWAY_EXCEPTION)
    java.lang.NoClassDefFoundError: Could not initialize class com.inquira.test.runtime.Trace
    at com.inquira.infra.gateway.Gateway.process(Gateway.java:468)
    at com.inquira.infra.gateway.Gateway.process(Gateway.java:303)
    at com.inquira.infra.gateway.soap.Gateway.process(Gateway.java:47)

    ReplyDelete
  147. Hi ,

    I got the below error when i try to start my WAS 7.0 using RAD, previously it was working good, after i restart my system it gives the error. Please help.

    Exception in thread "main" java.lang.NoClassDefFoundError: Files\IBM\SDP\runtimes\base_v7\profiles\AppSrv08.properties.wsjaas.conf -Djava.security.policy=D:\Program
    Caused by: java.lang.ClassNotFoundException: Files\IBM\SDP\runtimes\base_v7\profiles\AppSrv08.properties.wsjaas.conf -Djava.security.policy=D:\Program
    at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
    Could not find the main class: Files\IBM\SDP\runtimes\base_v7\profiles\AppSrv08/properties/wsjaas.conf -Djava.security.policy=D:\Program. Program will exit.

    ReplyDelete
  148. Hi,
    I get this message when I run a simple 'HelloSpring' program.
    ==============================
    Sep 04, 2013 6:27:39 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@248a4156: startup date [Wed Sep 04 18:27:39 IST 2013]; root of context hierarchy
    Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/env/DefaultEnvironment
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.(AbstractBeanDefinitionReader.java:57)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.(XmlBeanDefinitionReader.java:135)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:82)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
    at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
    at com.tutorialspoint.MainApp.main(MainApp.java:15)
    Caused by: java.lang.ClassNotFoundException: org.springframework.core.env.DefaultEnvironment
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 9 more
    ===========================================
    My Files are:
    HelloWorld.java:
    package com.tutorialspoint;

    public class HelloWorld {

    private String message;

    public void setMessage(String message) {
    this.message = message;
    }

    public void getMessage() {
    System.out.println("Your message: " + this.message);
    }
    }
    MainApp.java:
    package com.tutorialspoint;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    public class MainApp {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // Properties p = System.getProperties();
    // p.list(System.out);

    ApplicationContext context = new ClassPathXmlApplicationContext(
    "Beans.xml");
    HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
    obj.getMessage();
    }
    }
    Beans.xml:










    +++++++++++++++++
    I went through possible reasons suggested, but not able to resolve. Pls help.

    Thanks!

    ReplyDelete
  149. Hi, sir this program show run time error exception in thread "main" java.lang.NoClassdefFoundError:
    please help me remove the error in this program.
    program is given below...





    import java.lang.String;
    class ComLineText
    {
    public static void main(String[]args)
    {
    int count, i=0;
    String string;
    count=args.length;
    System.out.println("number of arguments="+count);
    while(i<count)
    {
    try
    {
    string=args[i];
    i=i+1;
    System.out.println(i+":"+"java is"+"string"+"!");

    }
    catch(Throwable t)
    {
    t.printStackTrace();
    }
    }
    }
    }

    ReplyDelete
  150. Help please. I have this project named executor on netbeans but when a I try to run it on command line (cmd.exe) using "java executor" I get this erro message.

    Exception in thread "main" java.lang.NoClassDefFoundError: executor (wrong name: executor/executor)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

    ReplyDelete
  151. Any idea, how to fix below error java.lang.NoClassDefFoundError: Could not initialize class com.tibco.tibrv.TibrvMsg, it's coming during building our application using Jenkins and due to this error lots of unit tests are failing.

    ReplyDelete
  152. I found one another common reason. If you create the java file inside a package using IDE like eclipse, you will find the package name on the top of your java file like "package pkgName". If you try to run this file from command prompt, you will get the NoClassDefFoundError error. Remove the package name from the java file and use the commands in the command prompt. Wasted 3 hours for this. -- Abhi

    ReplyDelete
  153. Hi All,

    I am facing this error when i create jar file and try to execute it with a .bat file. I have placed the classpath and varified it which dead correct.

    ERROR - Exception in PWCApplicationInitiator - applicationinitiator.PWCApplicationInitiator 67 main
    java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at com.matrixone.apps.domain.util.PropertyUtil.getProperty(PropertyUtil.java:88)
    at com.matrixone.apps.domain.util.ContextUtil.runInAnonymousContext(ContextUtil.java:287)
    at com.matrixone.apps.domain.DomainObject.(DomainObject.java:139)
    at com.pwc.dataloader.PWCSpinnerLoader.getRevisionForIPEC(PWCSpinnerLoader.java:491)
    at com.pwc.dataloader.PWCSpinnerLoader.loadClassificationInformationSpinner(PWCSpinnerLoader.java:422)
    at com.pwc.dataloader.PWCSpinnerLoader.loadClassificationInformationRelationshipSpinner(PWCSpinnerLoader.java:318)
    at com.pwc.dataloader.PWCSpinnerLoader.loadRelationshipDataToSpinner(PWCSpinnerLoader.java:80)
    at com.pwc.dataloader.PWCRFALoader.processMigUnitWrapper(PWCRFALoader.java:39)
    at com.pwc.applicationinitiator.PWCApplicationInitiator.configureInstance(PWCApplicationInitiator.java:93)
    at com.pwc.applicationinitiator.PWCApplicationInitiator.main(PWCApplicationInitiator.java:61)
    Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 22 more


    ReplyDelete
  154. i am getting 12 th type of NoclassDefFound error.
    please guide me

    java.lang.NoClassDefFoundError: Could not initialize class com.cordys.esbinternal.r1.CopyBookDefaultsCacheManager at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.eibus.xml.xpath.XPathMetaInfo.executeCustomFunction(XPathMetaInfo.java:386) at com.eibus.xml.xpath.XPath.evaluateAsXPathResult1(Native Method) at com.eibus.xml.xpath.XPath.evaluate(XPath.java:656) at com.cordys.bpm.utils.xpathevaluator.XPathEvaluatorUtil.evaluateXPathExpr(XPathEvaluatorUtil.java:50) at com.cordys.bpm.utils.xpathevaluator.XPathEvaluator.evaluateXPath(XPathEvaluator.java:72) at com.cordys.bpm.utils.xpathevaluator.EvaluateXPathSOAPRequestHandler.processRequest(EvaluateXPathSOAPRequestHandler.java:112) at com.cordys.bpm.service.BPMSOAPTransaction.process(BPMSOAPTransaction.java:48) at com.eibus.soap.SOAPTransaction.handleBodyBlock(SOAPTransaction.java:1379) at com.eibus.soap.SOAPTransaction.(SOAPTransaction.java:574) at com.eibus.soap.SOAPTransaction.(SOAPTransaction.java:238) at com.eibus.soap.Processor.onReceive(Processor.java:1066) at com.eibus.soap.Processor.onReceive(Processor.java:1039) at com.eibus.connector.nom.Connector.onReceive(Connector.java:475) at com.eibus.transport.NonTransactionalWorkerThreadBody.doWork(NonTransactionalWorkerThreadBody.java:61) at com.eibus.transport.NonTransactionalWorkerThreadBody.run(NonTransactionalWorkerThreadBody.java:26) at com.eibus.util.threadpool.WorkerThread.run(WorkerThread.java:64)

    ReplyDelete
  155. Tiered of this error
    ===============

    [12/24/13 17:05:47:199 IST] 00000032 annotation W com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses unable to instantiate class
    java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagSupport
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:363)
    at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:347)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:111)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
    at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.loadClass(WASAnnotationHelper.java:725)
    at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.collectClasses(WASAnnotationHelper.java:519)
    at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.(WASAnnotationHelper.java:140)
    at com.ibm.ws.webcontainer.annotation.WASAnnotationHelperManager.getAnnotationHelper(WASAnnotationHelperManager.java:59)
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:247)
    at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
    at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:732)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:617)

    ReplyDelete
  156. Exception in thread "main" java.lang.NoClassDefFoundError: bank
    Caused by: java.lang.ClassNotFoundException: bank
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
    Could not find the main class: bank. Program will exit.

    ReplyDelete
  157. pleae help me

    Jan 30, 2014 11:17:04 AM org.zkoss.zk.ui.impl.UiEngineImpl handleError
    SEVERE:
    java.lang.NoClassDefFoundError: javax/mail/Address
    at com.akarprima.kambium.view.controller.LeaveController$1.onEvent(LeaveController.java:121)
    at com.akarprima.kambium.view.controller.LeaveController$1.onEvent(LeaveController.java:1)
    at org.zkoss.zul.impl.MessageboxDlg.endModal(MessageboxDlg.java:107)
    at org.zkoss.zul.impl.MessageboxDlg$Button.onClick(MessageboxDlg.java:154)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2728)
    at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2663)
    at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136)
    at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1765)
    at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1550)
    at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1260)
    at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:603)
    at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:485)
    at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: javax.mail.Address
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    ... 38 more

    ReplyDelete
  158. Hello there, I am getting following error, while running QuickFIXJ sample application, namely Banzai and Executor. I have log4j and SLF4j Jars but still this error is troubling me a lot.

    Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
    at org.slf4j.LoggerFactory.(LoggerFactory.java:60)
    at quickfix.examples.banzai.Banzai.(Banzai.java:54)
    Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

    Please assist?

    ReplyDelete
  159. Hello anonymous, only include relevant log4j jar files (version 2.) , that would resolve this error. I have also encountered same error Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder, I had removed all of the log4j jar files except :"log4j-api-2.0-beta9.jar" and "log4j-core-2.0-beta9.jar",this has resolved the problem for me.

    ReplyDelete
  160. Hello I am getting the NoclassFound error in my java GUI application using 'swing' only when I run on Oracle Linux 5\6 platform. I do not get this error on any windows OS so not sure what's going on...
    Has anyone seen this before

    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: java/awt/Window$Type

    ReplyDelete
  161. Hi,

    I am getting below error :
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/ejb/SessionContext
    at amdocs.ar.general.util.ARBatchDaemon.main(ARBatchDaemon.java:32)
    Caused by: java.lang.ClassNotFoundException: javax.ejb.SessionContext
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 1 more



    I defined j2ee.jar in classpath as well which contains SessionContext.class, still getting the error,
    Please advice.


    CLASSPATH=/u01/app/oracle/product/11.2.0.3/client64/jdbc/lib/ojdbc6.jar:/usr/local/xerces-j-2_11_0/xercesImpl.jar:/usr/local/xerces-j-2_11_0/xml-apis.jar:/pkgbl01/inf/aimsys/ptewrk1/abp_home/core/applications/ginfj/lib/j2ee.jar:/pkgbl01/inf/aimsys/ptewrk1/abp_home/core/applications/ginfj/lib/j2ee.jar

    ReplyDelete
  162. it may because of in compatible jre..!!! check it out..
    ie, you have compiled it using say javac 6 compiler and tries to execute it with java 1.4 java.

    this will cause the error..

    ReplyDelete
  163. Getting below NoClassDefFoundError while trying to send email from Java program. I do have all the JAR required for sending email e.g. mail-1.4.5.jar , smtp-1.4.4..jar and activiation-1.1.jar but still getting below exception :
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
    at java.lang.Class.getMethod0(Class.java:2764)
    at java.lang.Class.getMethod(Class.java:1653)
    at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
    Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
    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)

    ReplyDelete
  164. I managed to resolve my problem, it was because of incorrect classpath. Even though I had all three required JAR and Java class file for program in same directory and I am running program from there, Java wasn't able to resolve that. I tried following command and it worked perfectly for me :

    java -cp mail-1.4.5.jar:smtp-1.4.4.jar:activation-1.1.jar:. JavaMailSender
    Sent email successfully....

    Also notice current directory denoted by dot (.) at very last of classpath argument. Since I was running my program on Linux, I have used colon as separator (:)

    ReplyDelete
  165. Is there someone having the NoClassDefFoundError using shared folders in Virtualbox?

    I have had a weird situation here. There are three virtual machines (two WinXP, one Win7) in my development machine, and in one of the WinXP machines I can't run jar files that are located in shared folders by Virtualbox (just the virtualbox folder, not the real ones), they crash with the NoClassDefFoundError error. In the other two machines works well, the same shared folder, the same jar, compiled with Netbeans with propper manifest and lib folder, under the same java version 1.7.0_51.

    Does anyone knows what is going on?

    ReplyDelete
  166. Hi,

    I am trying to create an end-point (JMS) for my middleware performance testing in IBM Rational Performance Tester. The following are the steps that I have followed for using JMS .jar files for TIBCO EMS Middleware Web Services, with the 'How to change the default JMS libraries in IBM Rational Performance Tester Technote (FAQ)' document as reference.

    1. Changed the jar files as per the doc attached since the protocol used it TIBCO EMS (JMS).
    2. Clicking the generic services client -> add an end point request.

    When I do this, I am getting the java.lang.NoClassDefFoundError in the exception trace log and am not able to proceed.


    Kindly provide your suggestions or solutions, to identify the root cause of the issue and to solve the same, in order to proceed further.


    Thanks and sincere regards.

    MohanKrishna B.
    Non-Functional Test Engineer (Performance)
    India: M: +91 99 62 834352 Qatar: M: +974 7090 1243

    ReplyDelete
  167. I am trying to run a program which suppose to create files in current directory but I am getting following error when running the class from command prompt:

    java -cp . TempFileDemo

    Exception in thread "main" java.lang.NoClassDefFoundError: FileNotFoundException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
    at java.lang.Class.getMethod0(Class.java:2764)
    at java.lang.Class.getMethod(Class.java:1653)
    at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
    Caused by: java.lang.ClassNotFoundException: FileNotFoundException
    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)
    ... 6 more

    Please help.

    ReplyDelete
  168. - Exception in CompatabilityFilter
    javax.servlet.ServletException: java.lang.NoClassDefFoundError: net.sf.cglib.proxy.Enhancer (initialization failure)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:239)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
    at com.fisglobal.CompatabilityFilter.doFilter(CompatabilityFilter.java:28)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:522)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:311)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:87)
    at

    ReplyDelete
  169. i am using httpmime jar files for Multipartentity for image upload and getting this NoClassDefFoundError

    E/AndroidRuntime(1116): FATAL EXCEPTION: main
    Process: crawes.product.iagent, PID: 1116
    java.lang.NoClassDefFoundError: org.apache.http.entity.mime.MultipartEntity
    at crawes.product.iagent.AddProduct.upload(AddProduct.java:186)
    at crawes.product.iagent.AddProduct.onClick(AddProduct.java:143)
    at android.view.View.performClick(View.java:4438)
    at android.view.View$PerformClick.run(View.java:18422)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    at dalvik.system.NativeStart.main(Native Method)

    ReplyDelete
  170. hi..
    i am using xdocreport libs for converting docx in to pdf on android plateform and getting these errors

    10-26 21:11:24.766: W/System.err(801): java.lang.NoClassDefFoundError: org.apache.poi.xwpf.usermodel.XWPFDocument
    10-26 21:11:24.766: W/System.err(801): at com.example.fileexplorer.FileexplorerActivity.createPDF(FileexplorerActivity.java:65)
    10-26 21:11:24.766: W/System.err(801): at com.example.fileexplorer.FileexplorerActivity.docConvert(FileexplorerActivity.java:36)
    10-26 21:11:24.778: W/System.err(801): at java.lang.reflect.Method.invokeNative(Native Method)
    10-26 21:11:24.778: W/System.err(801): at java.lang.reflect.Method.invoke(Method.java:525)
    10-26 21:11:24.786: W/System.err(801): at android.view.View$1.onClick(View.java:3628)
    10-26 21:11:24.786: W/System.err(801): at android.view.View.performClick(View.java:4240)
    10-26 21:11:24.796: W/System.err(801): at android.view.View$PerformClick.run(View.java:17721)
    10-26 21:11:24.796: W/System.err(801): at android.os.Handler.handleCallback(Handler.java:730)
    10-26 21:11:24.796: W/System.err(801): at android.os.Handler.dispatchMessage(Handler.java:92)
    10-26 21:11:24.805: W/System.err(801): at android.os.Looper.loop(Looper.java:137)
    10-26 21:11:24.805: W/System.err(801): at android.app.ActivityThread.main(ActivityThread.java:5103)
    10-26 21:11:24.805: W/System.err(801): at java.lang.reflect.Method.invokeNative(Native Method)
    10-26 21:11:24.816: W/System.err(801): at java.lang.reflect.Method.invoke(Method.java:525)
    10-26 21:11:24.816: W/System.err(801): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    10-26 21:11:24.825: W/System.err(801): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    10-26 21:11:24.825: W/System.err(801): at dalvik.system.NativeStart.main(Native Method)

    ReplyDelete
  171. I installed a cross compiler based on eclipse IDE. Eclipse could not start and shows an error message with the below log. Any solution to solve this? Thanks.

    Error log:

    !SESSION Mon Dec 08 17:26:56 IST 2014 ------------------------------------------
    !ENTRY org.eclipse.equinox.launcher 4 0 2014-12-08 17:26:56.306
    !MESSAGE Exception launching the Eclipse Platform:
    !STACK
    java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:626)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

    ReplyDelete
  172. java.lang.NoClassDefFoundError: sakila/ui/PharmaAdmin
    Caused by: java.lang.ClassNotFoundException: sakila.ui.PharmaAdmin
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main" Java Result: 1

    I have checked classpath, its correct only. I got this error please help me.

    ReplyDelete
  173. I get this error when trying to deploy on a unix box but no issues on my local weblogic server.
    User defined listener org.springframework.web.context.ContextLoaderListener failed: java.lang.NoClassDefFoundError: org/quartz/spi/ClassLoadHelper. java.lang.NoClassDefFoundError: org/quartz/spi/ClassLoadHelper at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2532) at java.lang.Class.getDeclaredConstructors(Class.java:1901) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:191) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:859) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:831) at

    help!! can't run my spring batch application on unix server

    ReplyDelete
  174. Hi,

    I am getting
    java.lang.NoClassDefFoundError:org/objectweb/asm/ClassVisitor when running Cobetura using ant. This issue is faced only one particular machine, the same is not reproducible when ran on other machines.
    Checked the classpath and the asm jar file is available in the classpath. Only option i have is uninstall the jdk1.6.0_x and install next version.

    Please let me know if there is anything else i need to check.

    Thanks.

    ReplyDelete
  175. Sometime, when you move from one version to another of same library or change the JAR file, you start getting this error, because earlier version was including a dependent JAR which is not includeded by newer version. To find out those dependent jar, you can take help of maven transitive dependency. If you are using Eclipse and Maven then you can check these trasitive depedency in Eclipse POM editor, alternatively you can also use mvn dependency:tree to see all transitive dependency in tree format. This is very helpful tool and helped me a lot to deal with NoClassDefFoundError due to update.

    ReplyDelete
  176. Hello,

    I am currently stuck at this problem and cannot find a solution. Appreciate your help.

    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/help/library/Book
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3040)
    at java.lang.Class.getMethod0(Class.java:3010)
    at java.lang.Class.getMethod(Class.java:1776)
    at ndi.util.Spawner.localSpawn(Spawner.java:167)
    at ndi.util.Spawner.spawn(Spawner.java:103)
    at Config.main(Config.java:18)
    Caused by: java.lang.ClassNotFoundException: oracle.help.library.Book
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    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)
    ... 8 more

    ReplyDelete
  177. I am getting this kind of error. App is running in j2ee env.

    java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory

    ReplyDelete
  178. Following error occured while integrating jcef browser (chromium based browser) as java project jar file in eclipse plugin project. Please suggest any possible reasons or solutions for this.

    [0601/131114:ERROR:child_process_launcher.cc(344)] Failed to launch child process
    CefApp: INITIALIZED
    F:\eclipse_sdk 3.7.2\eclipse\plugins\org.eclipse.equinox.launcher_1.2.0.v20110502.jar
    java.lang.NoClassDefFoundError: org/cef/handler/CefFocusHandler$FocusSource
    Caused by: java.lang.ClassNotFoundException: org.cef.handler.CefFocusHandler$FocusSource
    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:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    [0601/131114:ERROR:child_process_launcher.cc(344)] Failed to launch child process
    java.lang.NoClassDefFoundError: org/cef/handler/CefFocusHandler$FocusSource
    Caused by: java.lang.ClassNotFoundException: org.cef.handler.CefFocusHandler$FocusSource
    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:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    java.lang.NoClassDefFoundError: org/cef/handler/CefFocusHandler$FocusSource
    Caused by: java.lang.ClassNotFoundException: org.cef.handler.CefFocusHandler$FocusSource
    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:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

    Thanks in advance..
    By
    Divyanka Jain

    ReplyDelete
  179. Hi ,

    I am getting the below error in eclipse. Help me if any of you has a solution for this.

    Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
    at myform.Formsubmission.main(Formsubmission.java:11)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more

    ReplyDelete
  180. I really appreciate your taking the time to publish this. I'm getting the following exception in Eclipse when starting the Tomcat server. The error is thrown from a call made during Servlet Initialize code. The WAR project references a JAR project which has the Maven dependencies in it, and the jar and class files are there. Any help is greatly appreciated, here is the error message:
    SEVERE: StandardWrapper.Throwable
    java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/ArchiveEntry
    at com.ibm.util.merge.web.Initialize.init(Initialize.java:50)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5188)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.compress.archivers.ArchiveEntry
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
    ... 14 more

    Jun 11, 2015 4:14:45 PM org.apache.catalina.core.StandardContext loadOnStartup
    SEVERE: Servlet [Initialize] in web application [/IDMU_WAR] threw load() exception
    java.lang.ClassNotFoundException: org.apache.commons.compress.archivers.ArchiveEntry
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
    at com.ibm.util.merge.web.Initialize.init(Initialize.java:50)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5188)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

    ReplyDelete
  181. Hello @FlatBallFlyer, this error says that it is not able to find org/apache/commons/compress/archivers/ArchiveEntry class, which is inside commons-compress-1.4.1.jar file.

    Please add commons-compress-1.4.1.jar in your CLASSPATH e.g. inside your application's WEB-INF/lib directory and restart tomcat server.

    ReplyDelete
  182. @Anonymous, error java.lang.NoClassDefFoundError: com/google/common/base/Function means JVM is looking for a class called com.google.common.base.Function, which is likely from Google's Guava library but not able to found in your application's classpath.

    Please add guava-18.0.jar into your CLASSPATH, this should solve your problem , if you are facing this issue in Java Web application, put this JAR file into WEB-INF/lib folder.

    ReplyDelete
  183. Hi,
    I'm getting this error when my WAR is doployed on Tomcat (Centos server)
    javax.security.auth.login.LoginException: java.lang.NoClassDefFoundError: Could not initialize class org.jboss.ejb.client.EJBClient
    at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:221)
    at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:193)
    at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:176)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at fr.port.havre.capi.timad.jaas.impl.EjbContext.lookup(EjbContext.java:66)
    at fr.port.havre.capi.timad.jaas.impl.LoginModule.authenticate(LoginModule.java:168)
    at fr.port.havre.capi.timad.jaas.impl.LoginModule.login(LoginModule.java:200)
    ...

    But it works well when I deploy the same WAR on local Tomcat (Windows7) and it also works on a local VM (Ubuntu).

    More details :
    - org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:221) : doCreateProxy() invoke a static method called createProxy() which is in org.jboss.ejb.client.EJBClient class
    - The class org.jboss.ejb.client.EJBClient is located in a jar called "jboss-ejb-client-1.0.30.Final-redhat-1.jar"

    Thanks in advance,
    Mld.

    ReplyDelete
  184. Hello Mld, just check if JAR file jboss-ejb-client-1.0.30.Final-redhat-1.jar is present in WEB-INF/lib of your WAR file or in the lib directory of Tomcat home directory.

    ReplyDelete
  185. Hi, my program ist working fine as long as I run it in Netbeans. The second I try to run the deployed version I get following error:

    Exception in thread "main" java.lang.NoClassDefFoundError: Example.jar

    I have different frames in my application. Ones I press the button on the start frame nothing happens. The second frame that is supposed to pop up won't be displayed. I used Netbeans and have all the classes in the same package as public. In my code I simply start a new frame like this:

    NewFrame newFrame = new NewFrame();
    newFrame.setVisible(true);

    What am I doing wrong? Please help.

    ReplyDelete
  186. @DueWRP18, check what is your Main-Class attribute in manifest.mf file, you can find it inside META-INF folder of your JAR file. Use Winzip or WinRAR to open your JAR file. I am suspecting this attribute is not set properly and Java is not able to find main class to execute.

    ReplyDelete
  187. I am trying to use BalloonTip class.. Getting the below exception

    java.lang.NoClassDefFoundError: Could not initialize class net.java.balloontip.BalloonTip
    at com.businesslense.topology.client.JMapViewer.initializeZoomSlider(JMapViewer.java:474)
    at com.businesslense.topology.client.JMapViewer.(JMapViewer.java:209)
    at com.businesslense.topology.client.JMapViewer.(JMapViewer.java:173)
    at com.businesslense.topology.client.JMapViewerTree.(JMapViewerTree.java:49)
    at com.businesslense.topology.client.JMapViewerTree.(JMapViewerTree.java:38)
    at com.businesslense.topology.client.SLTopology.(SLTopology.java:106)
    at com.businesslense.topology.client.SLTopology.(SLTopology.java:183)

    Checked in the jar file also. BalloonTip is present.. And there is no static initializer block also from where this BallonTip is instantiated.

    ReplyDelete
  188. I am getting this error as well. I am using JDK 1.6 on solris.

    java -classpath /lawson/local/class:/lawson/local/jar/ojdbc6.jar:/lawson/local/jar/dom4j.jar:/lawson/local/jar/poi.jar:/lawson/local/jar/poi-ooxml.jar:/lawson/local/jar/poi-ooxml-schemas.jar:/lawson/local/jar/xmlbeans.jar test . file.txt
    Exception in thread "main" java.lang.NoClassDefFoundError: test
    Caused by: java.lang.ClassNotFoundException: test
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Could not find the main class: test. Program will exit.

    ReplyDelete
  189. Hi friends,

    I am facing this exception but in my locally its working when i upload the WAR files in cloud after iam getting this exception


    java.lang.NoClassDefFoundError: Could not initialize class java.awt.Font
    java.awt.font.TextLayout.singleFont(TextLayout.java:468)
    java.awt.font.TextLayout.(TextLayout.java:527)
    org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:208)
    org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1954)
    org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1937)
    com.SangamOne.ApnaKhata.dao.ExcelReportGeneratorApk.generateSimpleExcelReport(ExcelReportGeneratorApk.java:371)
    com.SangamOne.ApnaKhata.dao.ExcelReportGeneratorApk.getDealerxls(ExcelReportGeneratorApk.java:108)
    com.SangamOne.ApnaKhata.Controller.Xlspass.doGet(Xlspass.java:29)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

    please help me

    ReplyDelete
  190. Hi friends,

    i faced this is issue

    java.lang.NoClassDefFoundError: Could not initialize class [jar file name] ....

    but its not a class or jar file missing its entirely memory problem for me.
    i set the environment variable for increase java heap memory space.After its working fine.

    JAVA_OPTS="-server -Xms256m -Xmx1024m"

    thank you.

    java.lang.NoClassDefFoundError: Could not initialize class

    ReplyDelete
  191. Hello everyone,
    I got the error by runing the sample in: http://amitspiral.blogspot.pt/2015/05/generate-barcode-in-adf-12c.html

    log:
    Root cause of ServletException.
    java.lang.NoClassDefFoundError: org/krysalis/barcode4j/impl/code39/Code39Bean
    at barcode.ImageServlet.doGet(ImageServlet.java:77)
    ...

    Regards
    Carlos

    ReplyDelete
  192. i am getting this error when i store this applet in my user defined package called graphics



    C:\graphics>appletviewer demo18.html
    java.lang.NoClassDefFoundError: MyWholeApplet (wrong name: graphics/MyWholeApple
    t)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
    2)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:217)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:152)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:625)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:795)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:724)
    at sun.applet.AppletPanel.run(AppletPanel.java:378)
    at java.lang.Thread.run(Thread.java:722)

    ReplyDelete
  193. @Prateek, did you declare package graphics in your Applet class MyWholeApplet? Similarly to access that you need to use graphics.MyWholeApplet.

    ReplyDelete
  194. yaa i declare graphics to the very first line of my Appet code by
    package graphics;


    and to run i used command
    appletviewer graphics.demo

    demo is my html code in which my applet class get reside in it

    ReplyDelete
  195. If you are using HTML file then you don't need to use appletViewer to see it working, just open the HTML file. If you want to run Applet using appletViewer, just trying adding this line in your Applet class

    /* <applet code = "graphics.MyWholeApplet" width = 300 height = 300> </applet> */

    and run like

    appletViewer graphics.MyWholeApplet

    ReplyDelete
  196. C:\Program Files\Java\jdk1.7.0\bin>java createtable
    Exception in thread "main" java.lang.NoClassDefFoundError: createtable
    Caused by: java.lang.ClassNotFoundException: createtable
    at java.net.URLClassLoader$1.run(URLClassLoader.java:203)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

    ReplyDelete
  197. i found this error while running program in hadoop
    Exception in thread "main" java.lang.ClassNotFoundException: input
    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:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:278)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

    ReplyDelete
  198. I am trying to install Oracle 12c client jar file on my VM which is on Linux.I have installed JDK 1.8 on it. Whenever I try to install the Oracle client, I am facing this error -->
    Checking Temp space: must be greater than 415 MB. Actual 19301 MB Passed
    Checking swap space: must be greater than 150 MB. Actual 1018 MB Passed
    Checking monitor: must be configured to display at least 256 colors
    >>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo.
    Check if the DISPLAY variable is set. Failed (even though I set this)

    <<<<

    Some requirement checks failed. You must fulfill these requirements before continuing with the installation,

    Continue? (y/n) [n] y

    >> Ignoring required pre-requisite failures. Continuing...


    Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-04-06_12-46-41AM.
    Please wait ...[oracle@cacdtl03ag863v client32]$ Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit

    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:171)
    at java.awt.Toolkit$2.run(Toolkit.java:834)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
    at com.jgoodies.looks.LookUtils.isLowResolution(LookUtils.java:484)
    at com.jgoodies.looks.LookUtils.(LookUtils.java:249)
    at com.jgoodies.looks.plastic.PlasticLookAndFeel.(PlasticLookAndFeel.java:135)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:249)
    at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1852)
    at javax.swing.UIManager.setLookAndFeel(UIManager.java:557)
    at oracle.install.commons.util.Application.startup(Application.java:792)
    at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
    at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:198)
    at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:355)
    at oracle.install.ivw.client.driver.ClientInstaller.startup(ClientInstaller.java:89)
    at oracle.install.ivw.client.driver.ClientInstaller.main(ClientInstaller.java:99)

    Any suggestions to resolve this appreciated!

    ReplyDelete
  199. The previous post can be ignored. I found the resolution. It had something to do with the DISPLAY variable been set properly.

    ReplyDelete