Sunday, June 19, 2011

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

I know how frustrating is to see Exception in thread "main" java.lang.NoClassDefFoundError,  which is a manifestation of NoClassDefFoundError in Java. I have seen it couple of times and spent quite a lot time initially to figure out what is wrong , which class is missing etc. First mistake I did was mingling java.lang.ClassNotfoundException and NoClassDefFoundError, in reality they are totally different, and my second mistake was using trial and error method to solve this java.lang.NoClassDefFoundError instead of understanding why NoClassDefFoundError is coming, what is 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 which cannot be resolved or hard to resolve it’s just its manifestation which puzzles most of Java developer. This is the most common error in Java development along with java.lang.OutOfMemoroyError: Java heap space and java.lang.OutOfMemoryError: PermGen space  Anyway let’s see Why NoClassDefFoundError comes in Java and what to do to resolve NoClassDefFoundError in Java.



What is reason of NoClassDefFoundError in Java?

NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available during 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 name was provided during runtime not on compile time. Many Java developer mingle 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 below line in log when you get NoClassDefFoundError:

Exception in thread "main" java.lang.NoClassDefFoundError

Exception in thread “main” simply indicate that its “main” thread which is not able to find a particular class it could be any thread so just don’t worry . Difference between this error coming in main thread and other thread is , when Exception in thread “main” comes program crashes or shut it self 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 a times we confused ourselves with java.lang.ClassNotFoundException and java.lang.NoClassDefFoundError, though both of them related to Java Classpath they are completely different to each other. ClassNotFoundException comes when JVM tries to load a class at runtime dynamically means you give the name of class at runtime and then JVM tries to load it and if that class is not found in classpath it throws java.lang.ClassNotFoundException. While in case of NoClassDefFoundError the problematic class was present during Compile time and that's why program was successfully compile but not available during runtime by any reason. NoClassDefFoundError is easier to solve than ClassNotFoundException in my opinion because here we know that Class was present during build time but it totally depends upon environment, if you are working in J2EE environment than you can get NoClassDefFoundError even if class is present because it may not be visible to corresponding class loader. See my post NoClassDefFoundError vs ClassNotFoundException in Java for more details.



How to resolve java.lang.NoClassDefFoundError in Java

java.lang.NoClassDefFoundError in Java solution Obvious reason of 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) Class is not available in Java Classpath.

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

3) Any start-up script is overriding Classpath environment variable.
4) Because NoClassDefFoundError is a sub class 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 failure of static initialization is quite common.

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

We will now see couple of example and scenarios when java.lang.NoClassDefFoundError has came before and how its been resolved. This can help you to troubleshoot root cause of NoClassDefFoundError in Java application.


NoClassDefFoundError in Java - Example and Scenarios

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

2. Class is not in Classpath, there is no sure shot way of knowing it but many a 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 its working then it's sure short sign that some one is overriding java classpath.


NoClassDefFoundError in Java due to Exception in Static Initializer block

This is another common reason of java.lang.NoClassDefFoundError, when your class perform some static initialization in static block like many Singleton classes initialized itself on static block  to take advantage of thread-safety provided by JVM during class initialization process, and if static block throw 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 below code example, During class loading and initialization User class is throwing Exception from static initializer block, which trigger ExceptionInInitializerError during first time loading of User class in response to new User() call. Later rest of new User() are failing as java.lang.NoClassDefFoundError. 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 a  also a LinkageError which arises due to dependency on some other class , you can also get java.lang.NoClassDefFoundError if your program is dependent on native library and 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 ANT build file create JAR and manifest file than its worth noting to debug till that level to ensure that ANT build script is getting correct value of classpath and appending it to manifest.mf file.

7) Permission issue on JAR file can also cause NoClassDefFoundError in Java. If you are running your Java program in multi-user operating system like Linux than you should be using  application user id for all your application resources like JAR files, libraries and configuration. If you are using shared library which is shared among multiple application which runs under different users  then you may run with permission issue , like JAR file is owned by some other user and not accessible to your application. One of our reader “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 dependency on wrongly named bean. This is quite common on 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 same package while loading like in 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 class-loader structure and it depends upon 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 J2EE application knowledge of How ClassLoader works in Java is mandatory. Just to recap ClasLoader works on three principle delegation, visibility and uniqueness. Delegation means every request to load a class is delegated to parent classloader, visibility means ability to found classes loaded by classloader, all child classloader can see classes loaded by parent classloader but parent classloader can not see the class loaded by child classloaders. Uniqueness enforce that class loaded by parent will never be reloaded by child clasloaders. Now suppose if a class say User is present in both WAR file and EJB-JAR file and loaded by WAR classloader which is child classloader which loads class from EJB-JAR. When a code in EJB-JAR refer to this User class, Classloader which loaded all EJB class doesn’t found that because it was loaded by WAR classloader which is child of it. 

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


11) Some of reader of this blog also suggested that they get Exception 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 re-installing JDK. IF you are getting this error try to reinstall JDK . One of our reader got this issue after installing jdk1.6.0_33 and then reinstalling JDK1.6.0_25, he also has his JRE and JDK on different folder. See his comment also by searching JDK1.6.0_33 .


12) Java program can also throw java.lang.NoClassDefFoundError during linking which occurs during class loading in Java. One of the example of this scenario is just delete 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 is also just printing name of class as testing/User i.e. User class from 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 how to troubleshoot it, if you are facing with something new way than I listed above we will probably document if for benefit of others and again don’t afraid with Exception in thread "main" java.lang.NoClassDefFoundError.  


Other Exception and Error handling Tutorials from Javareivisted

169 comments :

Anonymous said...

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 ?

Javin said...

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

panbhatt said...

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.

Anusha said...

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.

Javin @ unsupportedclassversion error in java said...

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()

Anusha said...

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)

Javin @ eclipse debugging tutorial said...

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.

Xiaodong Xie said...

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

Anonymous said...

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

Anonymous said...

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.

Anonymous said...

/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?!

san said...

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?

Murad Iqbal said...

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.

Anonymous said...

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 ?

Javin @ hashmap and hashtable in java said...

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:

Naresh Kaushik said...

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.

Anand said...

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

JP @ String vs StringBuffer in Java said...

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

Anonymous said...

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?

Anonymous said...

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)

classnotfoundexception in java said...

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"

Anonymous said...

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?

Ethan said...

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

Anonymous said...

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.

Anonymous said...

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

Anonymous said...

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.

Rineez said...

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.

Javin @ Date To String in Java said...

@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

Anonymous said...

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 !!

Javin @ unsupportedClassVersionError in Java said...

@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.

Anonymous said...

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

Anonymous said...

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.

tita said...

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!

Javin @ String split Java said...

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.

It's me said...

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.

Javin @ substring in java said...

@"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.

Anonymous said...

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?

frenq said...

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

Ashwin said...

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.

adesh said...

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

Javin @ final in Java said...

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

adesh said...

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.

Javin @ parse xml file in java said...

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

Ashwin said...

Hi,

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

Javin @ ArrayList vs Vector in java said...

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.

adesh said...

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

Ashwin said...

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.

Swapnil said...

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)

Anonymous said...

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,

Anonymous said...

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!

Javin @ how to run Java Program said...

@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.

Bhadreswar said...

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.....

Jewl said...

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)

DMC Mihai said...

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

Javin @ how to run Java Program said...

@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%;

Keranatos said...

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)

Anonymous said...

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

Anonymous said...

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".

Javin @ Java Hashtable Example said...

@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.

P-H said...

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

Anonymous said...

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

Anonymous said...

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

Khushal said...

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

Anonymous said...

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.

Anonymous said...

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.

Anonymous said...

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!

Javin @ LinkedList vs ArrayList Java said...

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.

Anonymous said...

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.

Anonymous said...

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.

Javin @ sort array in java said...

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

Anonymous said...

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

Anonymous said...

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

Anonymous said...

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

Anonymous said...

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.

Anonymous said...

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)

Anonymous said...

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

Anonymous said...

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)

Anonymous said...

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?

Javin @ chmod examples in unix said...

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

anonymous said...

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 ....

Robert said...

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!

Anonymous said...

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.

Mary said...

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???

433a1326-9a12-11e1-a6db-000bcdcb2996 said...

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)

Surendra Kamble said...

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)

Anonymous said...

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?

Pankaj Soni said...

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)

Anonymous said...

compiled with sun jdk but run with bea jdk may also throw NoClassDefFoundError

p.Mohan said...

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.....

kisyell said...

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)

Anonymous said...

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.

Anonymous said...

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

Nick said...

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 :)

Soumya said...

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

P-H said...

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

Anonymous said...

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

Nikos Maravitsas said...

Hi,

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

Anonymous said...

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

Javin Paul said...

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

Javin @ Vector vs ArrayList said...

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

Anonymous said...

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.

Hassan said...

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.

Sabri said...

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.

Anonymous said...

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!!!!!!

Anonymous said...

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>

sukanya said...

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.

Unknown said...

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. :-)

Prashant Chauhan said...

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...

Anonymous said...

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

Anonymous said...

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

Javin @ CyclicBarrier Example Java said...

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.

Anonymous said...

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

Suril said...

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

Anonymous said...

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

Grilo said...

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

Anonymous said...

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)

Anonymous said...

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

Luke said...

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

Does enyone know the solution?
Thanks in advance,
Luke

Anonymous said...

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

Anonymous said...

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.

Anonymous said...

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();

Anonymous said...

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 :)

Anonymous said...

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.

Anonymous said...

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

Peter said...

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.

lrperfomance said...

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.

Anonymous said...

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

Cyril said...

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

Anonymous said...

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...

Javin @ ClassLoader in Java said...

@Anonymous, Please look into following tutorial, you should be able to find your answer
How ClassPath works in Java
How to set Path for Java in Windows and Linux
Difference between ClassPath and Path in Java

Eaiman Shoshi said...

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

Shari Das said...

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!

Argel Ramírez Reyes said...

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!

Anonymous said...

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)

Bharat Ravi said...

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 ??

Anonymous said...

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

Anonymous said...

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.

Rahul Raj said...

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

Anonymous said...

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.

Sanjiv Singh said...

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.

Marie said...

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

Javin @ linked list loop detection said...

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.

Anonymous said...

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.

Jonathan Patil said...

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.

Anonymous said...

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?

Anonymous said...

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

Joey said...

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)

Anonymous said...

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.

Soumya said...

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!

Bhavna Gupta said...

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();
}
}
}
}

Anonymous said...

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)

Anonymous said...

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.

Anonymous said...

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

Anonymous said...

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


Harish said...

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)

Sanjeev said...

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)

Madhusudan Dad said...

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.

zand said...

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

Anonymous said...

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?

Robin said...

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.

Anonymous said...

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

Ruchi Singh said...

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

Govind raj said...

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..

Anonymous said...

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)

Anonymous said...

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 (:)

Anonymous said...

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?

mohan krishna (a) krish said...

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

Anonymous said...

- 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

venkat said...

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)

Post a Comment