/ java.lang.NoClassDefFoundError: How to resolve – Part 2 ~ Java EE Support Patterns

6.15.2012

java.lang.NoClassDefFoundError: How to resolve – Part 2

This article is part 2 of our java.lang.NoClassDefFoundError troubleshooting series. It will focus on the more simple type of NoClassDefFoundError problem. This article is ideal for Java beginners and I highly recommend that you compile, run and study the sample Java program.
If not done already, I suggest that you first review the java.lang.NoClassDefFoundError - Part 1.

The following writing format will be used going forward and will provide you with:

-        Description of the problem case and type of NoClassDefFoundError.
-        Sample Java program “simulating” the problem case.
-        ClassLoader chain view.
-        Recommendations and resolution strategies.

NoClassDefFoundError problem case 1 – missing JAR file

The first problem case we will cover is related to a Java program packaging and / or classpath problem. A typical Java program can include one or many JAR files created at compile time. NoClassDefFoundError can often be observed when you forget to add JAR file(s) containing Java classes referenced by your Java or Java EE application.

This type of problem is normally not hard to resolve once you analyze the Java Exception and missing Java class name.

Sample Java program

** Tutorial video is now available: http://www.youtube.com/watch?v=Nn_Pq8cWiBg

The following simple Java program is split as per below:

-        The main Java program NoClassDefFoundErrorSimulator
-        The caller Java class CallerClassA
-        The referencing Java class ReferencingClassA
-        A util class for ClassLoader and logging related facilities JavaEETrainingUtil

This program is simple attempting to create a new instance and execute a method of the Java class CallerClassA which is referencing the class ReferencingClassA.It will demonstrate how a simple classpath problem can trigger NoClassDefFoundError. The program is also displaying detail on the current class loader chain at class loading time in order to help you keep track of this process. This will be especially useful for future and more complex problem cases when dealing with larger class loader chains.

#### NoClassDefFoundErrorSimulator.java
package org.ph.javaee.training1;

import org.ph.javaee.training.util.JavaEETrainingUtil;

/**
 * NoClassDefFoundErrorTraining1
 * @author Pierre-Hugues Charbonneau
 *
 */
public class NoClassDefFoundErrorSimulator {
       
       
        /**
         * @param args
         */
        public static void main(String[] args) {
               System.out.println("java.lang.NoClassDefFoundError Simulator - Training 1");
               System.out.println("Author: Pierre-Hugues Charbonneau");
               System.out.println("http://javaeesupportpatterns.blogspot.com");
              
               // Print current Classloader context
               System.out.println("\nCurrent ClassLoader chain: "+JavaEETrainingUtil.getCurrentClassloaderDetail());
              
               // 1. Create a new instance of CallerClassA
               CallerClassA caller = new CallerClassA();
              
               // 2. Execute method of the caller
               caller.doSomething();
              
               System.out.println("done!");
        }
}


#### CallerClassA.java
package org.ph.javaee.training1;

import org.ph.javaee.training.util.JavaEETrainingUtil;

/**
 * CallerClassA
 * @author Pierre-Hugues Charbonneau
 *
 */
public class CallerClassA {
       
        private final static String CLAZZ = CallerClassA.class.getName();
       
        static {
               System.out.println("Classloading of "+CLAZZ+" in progress..."+JavaEETrainingUtil.getCurrentClassloaderDetail());
        }
       
        public CallerClassA() {
               System.out.println("Creating a new instance of "+CallerClassA.class.getName()+"...");
        }
       
        public void doSomething() {
              
               // Create a new instance of ReferencingClassA
               ReferencingClassA referencingClass = new ReferencingClassA();             
        }
}

#### ReferencingClassA.java
package org.ph.javaee.training1;

import org.ph.javaee.training.util.JavaEETrainingUtil;

/**
 * ReferencingClassA
 * @author Pierre-Hugues Charbonneau
 *
 */
public class ReferencingClassA {

        private final static String CLAZZ = ReferencingClassA.class.getName();
       
        static {
               System.out.println("Classloading of "+CLAZZ+" in progress..."+JavaEETrainingUtil.getCurrentClassloaderDetail());
        }
       
        public ReferencingClassA() {
               System.out.println("Creating a new instance of "+ReferencingClassA.class.getName()+"...");
        }
       
        public void doSomething() {
               //nothing to do...
        }
}


#### JavaEETrainingUtil.java
package org.ph.javaee.training.util;

import java.util.Stack;
import java.lang.ClassLoader;

/**
 * JavaEETrainingUtil
 * @author Pierre-Hugues Charbonneau
 *
 */
public class JavaEETrainingUtil {
       
        /**
         * getCurrentClassloaderDetail
         * @return
         */
        public static String getCurrentClassloaderDetail() {
              
               StringBuffer classLoaderDetail = new StringBuffer();       
               Stack<ClassLoader> classLoaderStack = new Stack<ClassLoader>();
              
               ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
              
               classLoaderDetail.append("\n-----------------------------------------------------------------\n");
              
               // Build a Stack of the current ClassLoader chain
               while (currentClassLoader != null) {
              
                       classLoaderStack.push(currentClassLoader);
                      
                       currentClassLoader = currentClassLoader.getParent();
               }
              
               // Print ClassLoader parent chain
               while(classLoaderStack.size() > 0) {
                      
                       ClassLoader classLoader = classLoaderStack.pop();
                      
                       // Print current                     
                       classLoaderDetail.append(classLoader);
                      
                       if (classLoaderStack.size() > 0) {
                              classLoaderDetail.append("\n--- delegation ---\n");                               
                       } else {
                              classLoaderDetail.append(" **Current ClassLoader**");
                       }
               }
              
               classLoaderDetail.append("\n-----------------------------------------------------------------\n");
              
               return classLoaderDetail.toString();
        }
}


Problem reproduction

In order to replicate the problem, we will simply “voluntary” omit one of the JAR files from the classpath that contains the referencing Java class ReferencingClassA.

The Java program is packaged as per below:

-        MainProgram.jar (contains NoClassDefFoundErrorSimulator.class and JavaEETrainingUtil.class)
-        CallerClassA.jar (contains CallerClassA.class)
-        ReferencingClassA.jar (contains ReferencingClassA.class)

Now, let’s run the program as is:

## Baseline (normal execution)
..\bin>java -classpath CallerClassA.jar;ReferencingClassA.jar;MainProgram.jar org.ph.javaee.training1.NoClassDefFoundErrorSimulator

java.lang.NoClassDefFoundError Simulator - Training 1
Author: Pierre-Hugues Charbonneau
http://javaeesupportpatterns.blogspot.com

Current ClassLoader chain:
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@17c1e333
--- delegation ---
sun.misc.Launcher$AppClassLoader@214c4ac9 **Current ClassLoader**
-----------------------------------------------------------------

Classloading of org.ph.javaee.training1.CallerClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@17c1e333
--- delegation ---
sun.misc.Launcher$AppClassLoader@214c4ac9 **Current ClassLoader**
-----------------------------------------------------------------

Creating a new instance of org.ph.javaee.training1.CallerClassA...
Classloading of org.ph.javaee.training1.ReferencingClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@17c1e333
--- delegation ---
sun.misc.Launcher$AppClassLoader@214c4ac9 **Current ClassLoader**
-----------------------------------------------------------------

Creating a new instance of org.ph.javaee.training1.ReferencingClassA...
done!


For the initial run (baseline), the main program was able to create a new instance of CallerClassA and execute its method successfully; including successful class loading of the referencing class ReferencingClassA.

## Problem reproduction run (with removal of ReferencingClassA.jar)
../bin>java -classpath CallerClassA.jar;MainProgram.jar org.ph.javaee.training1.NoClassDefFoundErrorSimulator

java.lang.NoClassDefFoundError Simulator - Training 1
Author: Pierre-Hugues Charbonneau
http://javaeesupportpatterns.blogspot.com

Current ClassLoader chain:
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@17c1e333
--- delegation ---
sun.misc.Launcher$AppClassLoader@214c4ac9 **Current ClassLoader**
-----------------------------------------------------------------

Classloading of org.ph.javaee.training1.CallerClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@17c1e333
--- delegation ---
sun.misc.Launcher$AppClassLoader@214c4ac9 **Current ClassLoader**
-----------------------------------------------------------------

Creating a new instance of org.ph.javaee.training1.CallerClassA...
Exception in thread "main" java.lang.NoClassDefFoundError: org/ph/javaee/training1/ReferencingClassA
        at org.ph.javaee.training1.CallerClassA.doSomething(CallerClassA.java:25)
        at org.ph.javaee.training1.NoClassDefFoundErrorSimulator.main(NoClassDefFoundErrorSimulator.java:28)
Caused by: java.lang.ClassNotFoundException: org.ph.javaee.training1.ReferencingClassA
        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)
        ... 2 more


What happened? The removal of the ReferencingClassA.jar, containing ReferencingClassA, did prevent the current class loader to locate this referencing Java class at runtime leading to ClassNotFoundException and NoClassDefFoundError.

This is the typical Exception that you will get if you omit JAR file(s) from your Java start-up classpath or within an EAR / WAR for Java EE related applications.

ClassLoader view

Now let’s review the ClassLoader chain so you can properly understand this problem case. As you saw from the Java program output logging, the following Java ClassLoaders were found:

Classloading of org.ph.javaee.training1.CallerClassA in progress...
-----------------------------------------------------------------
sun.misc.Launcher$ExtClassLoader@17c1e333
--- delegation ---
sun.misc.Launcher$AppClassLoader@214c4ac9 **Current ClassLoader**
-----------------------------------------------------------------

** Please note that the Java bootstrap class loader is responsible to load the core JDK classes and is written in native code **

## sun.misc.Launcher$AppClassLoader
This is the system class loader responsible to load our application code found from the Java classpath specified at start-up.

##sun.misc.Launcher$ExtClassLoader
This is the extension class loader responsible to load code in the extensions directories (<JAVA_HOME>/lib/ext, or any other directory specified by the java.ext.dirs system property).

As you can see from the Java program logging output, the extension class loader is the actual super parent of the system class loader. Our sample Java program was loaded at the system class loader level. Please note that this class loader chain is very simple for this problem case since we did not create child class loaders at this point. This will be covered in future articles.

Recommendations and resolution strategies

Now find below my recommendations and resolution strategies for NoClassDefFoundError problem case 1:

-        Review the java.lang.NoClassDefFoundError error and identify the missing Java class
-        Verify and locate the missing Java class from your compile / build environment
-        Determine if the missing Java class is from your application code, third part API or even the Java EE container itself. Verify where the missing JAR file(s) is / are expected to be found
-        Once found, verify your runtime environment Java classpath for any typo or missing JAR file(s)
-        If the problem is triggered from a Java EE application, perform the same above steps but verify the packaging of your EAR / WAR file for missing JAR and other library file dependencies such as MANIFEST

Please feel free to post any question or comment. The part 3 is now available.

48 comments:

Thanks for this second part P-H. I must say you have covered it nicely especially on Classloader perspective which is major issue on J2EE environment. As I said earlier both your part 1 and this post effectively complement my post 3 ways to solve NoClassDefFoundError in Java J2EE. keep it up.

Javin

omg, i cant resolve this error:
java.lang.NoClassDefFoundError: org/hibernate/transform/ResultTransformer

I'm trying 3 days already but nothing :(.

Hi Haris,

Can you please provide more detail and the actual Exception Stack Trace of your error?

Thanks.
P-H

I also need help.
Here's my error,

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/lowagie/text/SplitCharacter
at net.sf.jasperreports.engine.JasperExportManager.exportToPdfFile(JasperExportManager.java:145)
at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:497)
at Main.getcashsales(Main.java:509)
at Main.access$2(Main.java:495)
at Main$5.mousePressed(Main.java:185)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.SplitCharacter
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)
... 37 more

I really have no idea how to solve this one. I'm guessing if it compiled, then the class wouldn't be missing. I'm just assuming though. I also tried including the jar file that has the class in the classpath but still nothing.

Hi Ananonymous,

Can you please give detail on your runtime environment and how you are packaging & deploying your application? What Im suspecting is the JAR file (iText.jar i assume) containing this missing class >> com/lowagie/text/SplitCharacter is not deployed to the right class loader.

The default class loader model, parent first, can cause some problem, especially if the JAR file is not deployed at the right place.

Regards,
P-H

Thanks for the immediate response. So, I'm using Eclipse. And there's this JMenuItem that when you click/press on it, it's suppose to generate a pdf file. These are the JAR files i needed for that to function:
* jasperreports-4.7.0.jar
* commons-logging-1.1.1.jar
* commons-digester-2.1.jar
* commons-beanutils-1.8.0.jar
* commons-collections-2.1.1.jar
* commons-javaflow-20060411.jar

So when i call on this,
JasperExportManager.exportReportToPdfFile(print,"reports/shift.pdf");

it generates noClassDefFoundError. I also tried including itextpdf-5.3.2.jar that has the SplitCharacter class in it but still no go.

Hi anonymous,

I found your problem. JasReports depends on iText for the PDF stuff related library. The itextpdf jar you are trying to use is the latest version. They did refactor lot of things so you cannot use this version. You will need to obtain the itext2.1.6. Try this link:
http://olex.openlogic.com/packages/itext/2.1.6

I also recommend that you check with the JasperReports community which version of itext they recommend you to use.

Download and import itext2.1.6.jar to your project and let me know if your problem is resolved.

Thanks.
P-H

Wow. Thanks. It's working now.
Can I just ask which part told you that? My mind is drawing out nothing.

Hi anonymous,

Don`t worry, NoClassDefFoundError is a hard problem which is why I created this article series. This article actually part was describing exactly your problem e.g. missing JAR file.

The missing piece of your analysis was to open the itext5.x version. You would have seen that the class was missing. Then I looked at earlier version of itext and found reference to 2.1.6.

Problem solved!

Thanks for your comments.
Regards,
P-H

Right. I just realized that the location was different. Thanks a bunch.

Hey P-H

Thanks for you article. I did get an insight on what the problem means but am still unable to figure out how to solve it. I have the similar issue and below if my ST

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.hadoop.hbase.util.Bytes.(Bytes.java:55)
at com.cccccc.flux.test.utility.HBaseTests.(HBaseTests.java:61)
at com.cccccc.landlord.topology.LandlordTopologyTest.testTopology(LandlordTopologyTest.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
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)
... 30 more

Any suggestions? If its a missing JAR how do I find it?


Hi noMad,

I suggest that you read my article part #3 as well. This missing class is part of the Apache commons logging which is referenced by org.apache.hadoop.hbase.util.Bytes. Can you please check your runtime classpath and see if Apache commons logging JAR file is included for the runtime classpath?

Thanks.
P-H

Hello P-H,

About this issue: I generated some custom java objects and I deployed them into a objects.jar file.
With JDeveloper, I generate a new code, let's say "Test.java", and I'm able to invoke, and correctly use, the java classes generated with this code.
Every thing is working running time, I modify the deployment profile of my Test.project and I add under WEB-INF/libs the object.jar file.
Once I deploy I get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/objects/MyList
at com.test.main(test.java:7)
Caused by: java.lang.ClassNotFoundException: com.objects.MyList
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.loadClassInternal(ClassLoader.java:320)
... 1 more

What should I do in this case?

Thank you in advance,

Robert

Hi, I get such message in Eclipse, while try run my selenium test:

java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:20)
at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:13)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
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)
... 18 more

How to fix this?
Thank you

Hi Robert,

java.lang.NoClassDefFoundError: com/objects/MyList

This error means that you did not include this referencing class to your WebApp class loader. The WebApp classloader did. find your test.java class file and not the referencing class: com/objects/MyList

Can you please confirm how you packaged com/objects/MyList inside your WebApp / WEB-INF?

Thanks.
P-H

Hi anonymous,

java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver

We can see from the Eclipse error that this is triggered from your JUnit test case execution. The problem is that your runtime classpath is missing the referencing library WebDriver; Google web automation tool library.

Please include this WebDriver library in your runtime classpath.

http://code.google.com/p/selenium/wiki/GettingStarted

Thanks.
P-H

Is there any way to simply turn off run time linking and force static linking as in a conventional program, so this problem just doesn't happen?

Hi Anonymous,

Not at this point with current Java specifications. Java classloader is a powerful concept but at the same time has some cons such as facing complex issues like NoClassDefFoundError.

At this point the best you can do is prevent problem to happen as much as you can and improve your classloader knowledge for faster troubleshooting & root cause analysis.

Thanks.
P-H

Hi,
I completely with your concept that prone the avoid of "Java.lang.RuntimeException: Unable to instantiate application com.restoID.RestoIDApp: java.lang.ClassNotFoundException:" than trying to debug it here is the stack of similar error I've been trying to debug unsuccessfully. I will really appreciate If you or someone in this forum can help.
Full stack:

ava.lang.RuntimeException: Unable to instantiate application com.restoID.RestoIDApp: java.lang.ClassNotFoundException:

Hi Toni,

We can see that your application is unable to find a particular class within RestoID. Can you please share the entire stack trace & error from your logs? We need to identify which class is missing from the classpath / class loader tree.

Thanks.
P-H

I have the same kind of class loader issue getting this at my Stack Trace.

Exception in thread "main" java.lang.NoClassDefFoundError: XxservreqSearchQueryHelperTest/java
Caused by: java.lang.ClassNotFoundException: XxservreqSearchQueryHelperTest.java
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.loadClassInternal(ClassLoader.java:320)
Could not find the main class: XxservreqSearchQueryHelperTest.java. Program will exit.

Hi Ruchi,

Your program is missing this class from the classpath/classloder:

XxservreqSearchQueryHelperTest.java

Is this a class from your application? Please where this class is located e.g. which JAR file and make sure it is part of your application classpath/classloader.

Regards,
P-H

Hello P-H

would you please take a look at this:

> java -classpath ./CallerClassA.jar;./ReferencingClassA.jar;MainProgram.jar
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.


-cp
-classpath
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D=
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:...|:]
-enableassertions[:...|:]
enable assertions with specified granularity
-da[:...|:]
-disableassertions[:...|:]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:[=]
load native agent library , e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument
-splash:
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
./ReferencingClassA.jar: line 2: package: command not found
./ReferencingClassA.jar: line 6: /bin: Is a directory
./ReferencingClassA.jar: line 7: CallerClassA.jar: command not found
./ReferencingClassA.jar: line 8: CallerClassA.jar: command not found
./ReferencingClassA.jar: line 9: CallerClassA.jar: command not found
./ReferencingClassA.jar: line 10: */: No such file or directory
./ReferencingClassA.jar: line 11: public: command not found
./ReferencingClassA.jar: line 13: syntax error near unexpected token `('
./ReferencingClassA.jar: line 13: ` private final static String CLAZZ = ReferencingClassA.class.getName();'
If 'MainProgram.jar' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf MainProgram.jar

It's opensuse 12.2

i've installed java following these steps
http://haulynjason.net/weblog/2011/12/setup-sun-jdk-on-opensuse/

Getting this error after using new slf4j jars that I have kept in classpath properly :
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory...
What shopuld I do now??

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

Hi I am having similar error:
java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.JFreeChart
at org.jfree.chart.ChartFactory.createLineChart(ChartFactory.java:1242)
at var.DatabaseLevelReport.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:288)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:562)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1018)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:196)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)

i am not able to figure anythign out. any help would be appreciated.

Hi anonymous,

You are likely missing a JAR file in your runtime classpath from JFreeChart. Please check your runtime classpath and make sure you included the proper JFreeChart libraries/JAR files.

Regards,
P-H

I have change 'open with ' setting of java class file ,now I 'm getting the error "Exception in thread "main" java.lang.NoClassDefFoundError: case1"
& my class file is also at proper location ,still I m getting this error ,

Hi, check for the location of case1 class. It looks like that you wrongly configured your runtime classpath from your Java IDE.

Regards,
P-H

As you have suggested i check my settings of case1 classpath but still ,
i m getting the error like,

C:\Program Files (x86)\Java\jdk1.7.0_11>java case1
Exception in thread "main" java.lang.NoClassDefFoundError: case1
Caused by: java.lang.ClassNotFoundException: case1
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: case1. Program will exit.

& also the icon of java class file shows symbol of cmd...
i think that's y the cmd is not able to find the classfile of "case1" ?
Now ,i can't understand how to solve this?
I have uninstall all previous jdk & now i reinstall it then also the symbol of java class file is remain as it is(cmd).

Hi, Please help me to fix this issue
C:\Jars>javac -cp "C:\Program Files\Java\selenium\*.jar";"OneReports.jar";"testn
g.jar" test\TestngTestSuiteUsingXML.java

C:\Jars>java -cp "C:\Program Files\Java\selenium\*.jar";"OneReports.jar";"testng
.jar" test.TestngTestSuiteUsingXML
[[TestNGClassFinder]] Unable to read methods on class test.LoginOneReports - una
ble to resolve class reference org/openqa/selenium/WebDriver
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/W
ebDriver
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
at org.testng.internal.TestNGClassFinder.(TestNGClassFinder.java:5
9)
at org.testng.TestRunner.initMethods(TestRunner.java:409)
at org.testng.TestRunner.init(TestRunner.java:235)
at org.testng.TestRunner.init(TestRunner.java:205)
at org.testng.TestRunner.(TestRunner.java:153)
at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRu
nner.java:522)
at org.testng.SuiteRunner.init(SuiteRunner.java:157)
at org.testng.SuiteRunner.(SuiteRunner.java:111)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1289)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1057)
at test.TestngTestSuiteUsingXML.main(TestngTestSuiteUsingXML.java:20)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
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)
... 18 more

C:\Jars>

Hi,

The problem is with your classpath definition, you have to specify each JAR file by itself, remove the *.jar, add each JAR from Selenium individually.

Thx
P-H

hi..

i have checked out the project from svn..its is giving problem in tomcat saying
FileNotFoundException gsapp.properties
i had set the path of gsapp file but still the same error..

and the project i have checked out giving dependencies error..

Hi Please Help me to fix This issue
I have This Error That i don't know how to solve,I Don't Know What is Wrong,
Pretty Please Help,.

(My Ireport) C:\Program Files\Java\jre7\iReport-5.5.0


Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at net.sf.jasperreports.engine.util.JRLoader.(JRLoader.java:68)
at net.sf.jasperreports.engine.JRPropertiesUtil.loadProperties(JRPropertiesUtil.java:99)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.initProperties(DefaultJasperReportsContext.java:94)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.(DefaultJasperReportsContext.java:71)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.(DefaultJasperReportsContext.java:59)
at net.sf.jasperreports.engine.JasperCompileManager.getDefaultInstance(JasperCompileManager.java:84)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:459)
at Report.bReportActionPerformed(Report.java:110)
at Report.access$000(Report.java:12)
at Report$2.actionPerformed(Report.java:83)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

Hi I have a problema
java.lang.ClassNotFoundException: com.sun.pdfview.PDFFile ------------------------- Loader Info ------------------------- ClassLoader name: [sap.com/internos] Loader hash code: 587dd2bd Living status: alive Direct parent loaders: [system:Frame] [interface:webservices] [interface:cross] [interface:security] [interface:transactionext] [library:webservices_lib] [library:opensql] [library:jms] [library:ejb20] [service:p4] [service:ejb] [service:servlet_jsp] [library:tc~ddic~runtime~facade] [library:tc~bl~logging~api] [library:tc~bl~exception~lib] [sap.com/tc~wd~api] [library:tc~cm~arfc2~api] Resources: D:\usr\sap\CPD\J00\j2ee\cluster\apps\sap.com\internos\servlet_jsp\webdynpro\resources\sap.com\internos\root\WEB-INF\lib\sap.com~internos.jar ---------------------------------------------------------------

I am Using PDFRenderer-0.9.1.jar on webdynpro as java 7.3

My problem.

cannot Deploy Glassfish.jsp on eclipse Luna, with JDK 8, glassfish 4.1.


Even Details


Exception Stack Trace:



org.glassfish.tools.ide.admin.CommandException: Cannot initialize Runner class
at org.glassfish.tools.ide.admin.AdminFactory.newRunner(AdminFactory.java:180)
at org.glassfish.tools.ide.admin.AdminFactoryHttp.getRunner(AdminFactoryHttp.java:110)
at org.glassfish.tools.ide.admin.ServerAdmin.exec(ServerAdmin.java:75)
at oracle.eclipse.tools.glassfish.GlassfishServerBehaviourDelegate.publishDeployedDirectory(GlassfishServerBehaviourDelegate.java:608)
at oracle.eclipse.tools.glassfish.GlassfishV4ServerBehavior.publishModuleForGlassFishV3(GlassfishV4ServerBehavior.java:96)
at oracle.eclipse.tools.glassfish.GlassfishV4ServerBehavior.publishModule(GlassfishV4ServerBehavior.java:56)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publishModule(ServerBehaviourDelegate.java:1091)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publishModules(ServerBehaviourDelegate.java:1183)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:987)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3157)
at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:345)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Session Data:



eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_25
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=es_MX
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

Hi Tryu,

I do not see any reference to NoClassDefFoundError. Can you please share any other error leading to this Runner class init failure.

Thanks.

the error is when i add the jsp at the server, and send this message:

cannot Deploy Prueba1
Cannot initialize Runner class

Prueba1 is my .jsp, and the bafore code was in the log

the problem is when i add the .jsp or .html at glassfish server, is non deployed, and stop.

Glassfish is 4.1
Eclipse Luna 4.4.1
JDK 8

Hello,

is there a simple solution for this problem:

Last login: Wed Dec 10 21:47:08 on console
MacSpare2:~ imaci7$ /Applications/TinyUmbrella.app/Contents/MacOS/umbrella-tool
Drawing [TinyUmbrella: Verifying Libraries...]
Drawing [Unable to validate libraries... loading anyway...]
Drawing [TinyUmbrella: Reticulating splines...]
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: ch/randelshofer/quaqua/SheetListener
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at com.semaphore.os.UIHandlerManager.(UIHandlerManager.java:17)
at com.semaphore.TinyUmbrella.(TinyUmbrella.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at com.semaphore.TinyLoader.loadTiny(TinyLoader.java:255)
at com.semaphore.TinyLoader.access$300(TinyLoader.java:29)
at com.semaphore.TinyLoader$1$1.run(TinyLoader.java:47)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.ClassNotFoundException: ch.randelshofer.quaqua.SheetListener
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)
... 23 more

Thank you very much for your help!
Greetings, Arnoud

Hi i have also noClassDefFoundError but with no cause by data. The sam war works well on localhost but deploying on Linux get an error. Postgress 9.3,Jboss 7.1.1, Hibernate 4.0.1

This is partial stack trace. Any help is much apreciated.

root cause

java.lang.NoClassDefFoundError: Could not initialize class com.example.test.SessionFactoryUtil
com.example.dao.PrijevoznikDAO.getAll(PrijevoznikDAO.java:19)
com.example.clara.main.PrijevozniciMain.(PrijevozniciMain.java:74)
com.example.clara1.Clara1UI.init(Clara1UI.java:351)
com.vaadin.ui.UI.doInit(UI.java:639)
com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222)
com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1402)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:305)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

Mine previous post wasnt formated well.

when war is deployed localy it works fine, but on Linux it gets this error.

Hi! Could you guide me to resolve the following error
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/index/IndexableField
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.index.IndexableField
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more

Hi, please help me to fix this error
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:800)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
java.net.URLClassLoader.access$100(URLClassLoader.java:71)
java.net.URLClassLoader$1.run(URLClassLoader.java:361)
java.net.URLClassLoader$1.run(URLClassLoader.java:355)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:354)
java.lang.ClassLoader.loadClass(ClassLoader.java:425)
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
java.lang.ClassLoader.loadClass(ClassLoader.java:358)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:800)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
java.net.URLClassLoader.access$100(URLClassLoader.java:71)
java.net.URLClassLoader$1.run(URLClassLoader.java:361)
java.net.URLClassLoader$1.run(URLClassLoader.java:355)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:354)

This is my error. i using spring aspectj. and there is a file call config.xml.which will have the beans



INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@5c71f6ca: startup date [Tue Apr 12 03:09:37 IST 2016]; root of context hierarchy
Apr 12, 2016 3:09:37 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [config.xml]
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1011)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:957)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.mtit.gui.BookGUI.(BookGUI.java:23)
at com.mtit.gui.BookGUI$1.run(BookGUI.java:34)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Hi..plz help me to fix this error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
at Extraction.main(Extraction.java:85)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more

I am used string utility function to split the syslog data

java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:18)
at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 18 more

I need help pls

Post a Comment