What is Exception in thread "main" java.lang.NoClassDefFoundError?
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 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 ClassLoader. See my post NoClassDefFoundError vs ClassNotFoundException in Java for more details.
How to resolve java.lang.NoClassDefFoundError:
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 Classloaders 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
4) 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");
}
}
* 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)
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)
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
145 comments:
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 ?
Can you post exact error or exception java.lang.NoClassDefFoundError comes due to many different reason.
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.
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.
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()
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)
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.
should be System.getProperty("java.class.path") instead of System.getproperty("java.classpath"), at least for jdk1.6.0_25.
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
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.
/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?!
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?
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.
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 ?
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:
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.
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
Hi Anand can you post full error for which class its giving java.lang.NoClassDefFoundError ?
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?
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)
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"
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?
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
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.
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
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.
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.
@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
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 !!
@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.
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
thank you very much
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.
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!
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.
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.
@"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.
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?
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
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.
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
Hi adesh, is that coming from Applet, it looks to me as security policy issue, providing your Applet necessary permission may help.
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.
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
Hi,
I have posted 1 issue in Jan-05. Could you help me out to resolve on the same.
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.
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
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.
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)
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,
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!
@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.
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.....
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)
Thank you very much, my problem was the second one on your list.
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
@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%;
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)
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
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".
@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.
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
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
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
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
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.
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.
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!
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.
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.
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.
do you have typo here grui/GUI is it "grui" or "gui" ?
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
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
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
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.
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)
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
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)
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?
try running HelloWorld with -classpath . option from the same directory where you have HelloWorld class file.
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 ....
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!
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.
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???
I have even a better solution. Switch to Visual Studio and Microsoft.
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)
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)
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?
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)
compiled with sun jdk but run with bea jdk may also throw NoClassDefFoundError
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.....
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)
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.
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
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 :)
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
You are great !!! Helped me identify the source of the issue and fix it..
@Tanish
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
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
Hi,
Nice blog! Is there an email address I can contact you in private?
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
@Nikos, Thanks. you can reach me at savingfunda@gmail.com
@Sam, Glad you hear that you got your Java environment setup properly. looks like re installation of Java, set Java PATH variable properly.
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.
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.
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.
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!!!!!!
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>
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.
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. :-)
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...
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
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
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.
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
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
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
if you type
java MyClass.class
you will get NoClassDefFoundError
You must type only the file name:
java MyClass
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)
hi all, when I'm using netbeans everything works fine. But the same program gives noclassdeffounderror with cmd. any idea why this is happening?
"Uncaught Exception:java.lang.NoClassDefFoundError" on BlackBerry app.
Does enyone know the solution?
Thanks in advance,
Luke
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
Thank you very much for your post. The Junit solution works for TestNG also.
Thanks! Your post helped me a lot in fixing my problems!
Keep the good job up!!
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.
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();
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 :)
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.
plz,
send solution of
Exception in thread "main" java.lang.NoClassDef
FoundError: Files\Java\jdk1/6/0_0
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.
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.
I'm getting Exception in thread "main" java.lang.NoClassDefFoundError: while using static inner class
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
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...
@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
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
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!
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!
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)
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 ??
How to fix exception in thread main java.lang.noclassdeffounderror wrong name this problem mate, Can anyone please help here
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.
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
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.
Post a Comment