NoClassDefFoundError error on Mac with NetBeans - java

I am getting a NoClassDefFoundError error when I run my program. Here is the stack trace:
Exception in thread "main" java.lang.NoClassDefFoundError: ex7/Ex7
Caused by: java.lang.ClassNotFoundException: ex7.Ex7
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)
Java Result: 1
How do I fix this? I'm on a Mac and running NetBeans.

It seems class Ex7class from package ex7 isn't in classpath. recheck the class try clean build

Related

java.lang.NoClassDefFoundError: when trying to debug in eclipse

I was trying to Debug my application by running it from Eclipse after passing the arguments in the Debug configuration > Arguments . But im getting the error as below
java.lang.NoClassDefFoundError: C:\bea\jrockit_160_05\jre\bin\java
Caused by: java.lang.ClassNotFoundException: C:\bea\jrockit_160_05\jre\bin\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: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"
"C:\bea\jrockit_160_05\jre\bin\java" -Xms256m -Xmx256m -XX:PermSize=64M -XX:MaxPermSize=1000M ---------etc
etc are the arguments im passed .
Please help me to resolve this

WSDL Exception in webservice

I created my first axis2 webservice and I got following error when I try to invoke the web service through my client which is created using stub.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/wsdl/WSDLException
at com.test.first.TestStub.populateAxisService(TestStub.java:41)
at com.test.first.TestStub.<init>(TestStub.java:88)
at com.test.first.TestStub.<init>(TestStub.java:77)
at com.test.first.TestStub.<init>(TestStub.java:126)
at com.test.first.TestStub.<init>(TestStub.java:118)
at com.test.first.TestTest.main(TestTest.java:11)
Caused by: java.lang.ClassNotFoundException: javax.wsdl.WSDLException
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(Laun``cher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more
What could be the root cause for this exception?
Note: I have included wsdl4j and log4j libraries.
Likely a classpath issue? Can't find javax.wsdl.WSDLException. Ensure this is available.

Having issues trying to run a standalone Java 6 program which is packaged in a war file and deployed under tomcat 7

The issue is that when I run it via Eclipse Juno by clicking on it and "Run as Java Application" it works,
but it needs to be to run in a Linux shell script or at least from the Linux shell.
I need it to append all the jar files from $CATALINA_HOME/webapps/myapp/WEB-INF/lib to my classpath.
Here's my code:
package com.myapp.client;
public class ClientApp {
public static void main(String args[]) {
System.out.println("Hi Client");
}
}
When I cd into $CATALINA_HOME/webapps/myapp/WEB-INF/classes/com/myapp/client issue the following command:
java -classpath "/home/devuser/DevTools/apache-tomcat-7.0.32/webapps/myapp/WEB-INF/lib/*:." ClientApp
I receive this exception:
Exception in thread "main" java.lang.NoClassDefFoundError: ClientApp (wrong name: com/myapp/client/ClientApp)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
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: ClientApp. Program will exit
When I go to my home dir (/home/devuser) and type this in, it still doesn't work:
java -classpath "/home/devuser/DevTools/apache-tomcat-7.0.32/webapps/myapp/WEB-INF/lib/*:." $CATALINA_HOME/webapps/myapp/WEB-INF/classes/com.myapp.ClientApp
Exception in thread "main" java.lang.NoClassDefFoundError: /home/devuser/DevTools/apache-tomcat-7/0/32/webapps/myapp/WEB-INF/classes/com/myapp/ClientApp
Caused by: java.lang.ClassNotFoundException: .home.devuser.DevTools.apache-tomcat-7.0.32.webapps.myapp.WEB-INF.classes.com.myapp.ClientApp
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: /home/devuser/DevTools/apache-tomcat-7.0.32/webapps/myapp/WEB-INF/classes/com.myapp.ClientApp. Program will exit.
Thank you for taking the time to read this... Would appreciate it if someone could assist me.
All of your libraries and classes need to be in your classpath, then the next argument is the path to your class.
java -cp '.:/path/to/libdir/*:/path/to/myapp.war' com.myapp.client.ClientApp

I put the xmlbeans-2.3.0.jar into path and it says another exception while reading .xslx file using apache poi

I put the xmlbeans-2.3.0.jar into path and it says another exception while reading .xslx file using apache poi.
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:149)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:136)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:54)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:98)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:199)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:178)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:53)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:176)
at setTargetPlan.setTask(setTargetPlan.java:152)
at userVerification.main(userVerification.java:204)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
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)
... 10 more
Same as your earlier problem.
For each ClassNotFound exception, search for the jar on the site below which contains this class and put the jar in your classpath
http://www.jarfinder.com/index.php/java/info/org.dom4j.DocumentException shows you need dom4j.jar

java.lang.NoClassDefFoundError

i am geting following error
Am i missing some jar file?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.slf4j.impl.JCLLoggerFactory.getLogger(JCLLoggerFactory.java:69)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:243)
at org.smslib.helper.Logger.<init>(Logger.java:34)
at org.smslib.Service.<init>(Service.java:93)
at SendMessage.doIt(SendMessage.java:28)
at SendMessage.main(SendMessage.java:82)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
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 sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 6 more
Java Result: 1
Yes, you need the Apache Logging JAR file on your classpath. Download it here: http://commons.apache.org/downloads/download_logging.cgi
Adding the jar files to ant lib will make them available for ant's java process and not your applications java process. Setting your application's classpath correctly must work.

Categories

Resources