I have a webservice client created using cxf. When I run from eclipse I dont get any errors. But when I create a jar out of the files and run it from cmd prompt , I get NoclassDef exception or ClassNot found exception. I have set the classpath, java home correct.
1. Exception
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
2. Exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/cxf/databinding/DataBinding
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.databinding.DataBinding
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 java.lang.ClassLoader.loadClassInternal(Unknown Source)
The web service is in C# wcf and the client was created without JAXBinding element.
Anyhelp will be appreciated.
Thanks,
Priya.R
This is a typically and easiy-to-solve classpath problem: The cxf library (-ies) is/are missing on the classpath. Start the application like this:
java -cp <youJar.jar>;<cxf.jar>[;<another-cxf.jar>;...] my.pkg.Application
You'll have to replace the name of the main class and the values of the -cp parameter with the paths and names of your jar and all other libraries that are required to run the application.
Why does it work from eclipse: In eclipse, you've set the build path correctly, but this builds path is not exported or added to the jar.
Related
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
at org.apache.commons.httpclient.methods.ExpectContinueMethod.<init>(ExpectContinueMethod.java:93)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.<init>(EntityEnclosingMethod.java:119)
at org.apache.commons.httpclient.methods.PostMethod.<init>(PostMethod.java:106)
at SMSServiceJava.CSoftHttpClientSMSService.sendSimpleSMS(CSoftHttpClientSMSService.java:113)
at SMSServiceJava.CSoftHttpClientSMSService.main(CSoftHttpClientSMSService.java:219)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException
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)
... 6 more
whenever I am running the program in eclipse I am getting the above mentioned exception. whenever I already been passed the relevant package in my classpath. can anyone tell me how to resolve this?
Add the jar(Commons-codec.jar) file needed for this org.apache.commons.codec.DecoderException
Download it from here and put it in classpath
http://commons.apache.org/proper/commons-codec/download_codec.cgi
You need commons-codec.jar on your classpath.
Reference: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
Please make sure that org-apache-commons-codec.jar is present on your class-path. You can download this commons-codec jar file from apache website.
This jar file contains org/apache/commons/codec/DecoderException class, and hence add it to the classpath must resolve your problem.
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.
For more
Try to include commons-codec-XXX.jar.
Well, I exported my application into JAR with eclipse, but now whenever I try running it I get the: "A Java Exception has occurred". When I try to run it through command line it says:
C:\Users\Arturas>java -jar D:\Dropbox\EclipseWorkspace\Exports\Dantracio_skaiciu
oklis3.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widge
ts/Composite
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 sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Composite
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)
... 6 more
C:\Users\Arturas>
Any solutions to this? I just hate java for this... It never works on desktops when you want it to... sorry I'm really stressed out from this, I'm overreacting...
Any ideas what could cause this? I doesn't work on other computers as well. Right now it's using Java 1.7. And the application runs perfectly on Eclipse.
You need to get your dependencies. Looks like you are depending on swt, which is not part of the core java language. You'll need to get all the third party jars that you depend on and include them in your classpath. It runs perfectly on eclipse because eclipse takes care of setting up the classpath for you.
You can set the classpath in your manifest file as described in the documentation, or you could include a script to start your application that will use the -cp command when running the jar, or you can use something that will package everything into one monster jar like the solutions to this question.
I am trying to setup OFBiz in my computer. So far, I have followed the step by step procedure on installing the software. The problem is when I try to run the server by executing the command java -jar ofbiz.jar I always encounter a startup exception. Even if I execute the startofbiz.bat it will display the same error:
org.ofbiz.base.start.StartupException: Cannot locate container class (org.ofbiz.service.rmi.RmiServiceContainer)
at org.ofbiz.base.container.ContainerLoader.loadContainer(ContainerLoader.java:164)
at org.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:65)
at org.ofbiz.base.start.Start.initStartLoaders(Start.java:259)
at org.ofbiz.base.start.Start.init(Start.java:96)
at org.ofbiz.base.start.Start.main(Start.java:410)
java.lang.ClassNotFoundException: org.ofbiz.service.rmi.RmiServiceContainer
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 org.ofbiz.base.util.CachedClassLoader.loadClass(CachedClassLoader.java:196)
at org.ofbiz.base.util.CachedClassLoader.loadClass(CachedClassLoader.java:169)
at org.ofbiz.base.container.ContainerLoader.loadContainer(ContainerLoader.java:162)
at org.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:65)
at org.ofbiz.base.start.Start.initStartLoaders(Start.java:259)
at org.ofbiz.base.start.Start.init(Start.java:96)
at org.ofbiz.base.start.Start.main(Start.java:410)
java.lang.ClassNotFoundException: org.ofbiz.service.rmi.RmiServiceContainer
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 org.ofbiz.base.util.CachedClassLoader.loadClass(CachedClassLoader.java:196)
at org.ofbiz.base.util.CachedClassLoader.loadClass(CachedClassLoader.java:169)
at org.ofbiz.base.container.ContainerLoader.loadContainer(ContainerLoader.java:162)
at org.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:65)
at org.ofbiz.base.start.Start.initStartLoaders(Start.java:259)
at org.ofbiz.base.start.Start.init(Start.java:96)
at org.ofbiz.base.start.Start.main(Start.java:410)
Please help!
Assuming you've run the ant run-install step as you have been following step by step instructions you should debug the exception like you would any other java exception.
Firstly in your stack trace the key lines to look at are:
{org.ofbiz.base.start.StartupException: Cannot locate container class
(org.ofbiz.service.rmi.RmiServiceContainer)}
{java.lang.ClassNotFoundException:
org.ofbiz.service.rmi.RmiServiceContainer}
These are telling you that the class, org.ofbiz.service.rmi.RmiServiceContainer, was attempted to be loaded and was not found.
You should check to see whether you have the class file RmiServiceContainer.class. In my installation of OFBiz this class is located under:
/ofbiz/framework/service/build/classes/org/ofbiz/service/rmi/RmiServiceContainer.class
If you find the class file then try rebuilding OFBiz using ant refresh.
If you could not find the class file then search for the java file that is used to create this class RmiServiceContainer.java. The java code that is compiled to created this class is located under:
/ofbiz/framework/service/src/org/ofbiz/service/rmi/RmiServiceContainer.java
If you find the Java file, again, try and rebuild OFBiz using ant refresh and confirm the class file was created. If you cannot find the java file then you should download OFBiz again.
If running ant refresh fails to fix the issue then it's likely something isn't configured correctly in your classpath.
I am using JavamailAPI, I downloaded and installed the javamail-1.4.4 and jaf-1.1.1.
Added the mail.jar and activation.jar to the CLASSPATH. Ii am able to compile the msgsend class, when i trying to run the msgsend class i am getting the following exception.
Exception in thread "main" java.lang.NoClassDefFoundError: msgsend/java
Caused by: java.lang.ClassNotFoundException: msgsend.java
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: msgsend.java. Program will exit.
Please any can help me in solving this issue.
Thanks in advance..
Looks like you are trying to launch your program by
java msgsend.java
but the java expects a class name, not a file name.
java msgsend
Also, class names in Java should be upper-case.
First, you will need to compile your msgsend.java using javac and then run it as follows:
java msgsend
See that I removed the .java extension as java will look for msgend.class.
I am trying to create the java files from a remote webservice. I downloaded axis 1.4, copied the lib folder to c:\data\axis\lib which contains of these files:
axis.jar
axis-ant.jar
commons-discovery-0.2.jar
commons-logging-1.0.4.jar
jaxrpc.jar
log4j.properties
log4j-1.2.8.jar
saaj.jar
wsdl4j-1.5.1.jar
I added the c:\data\axis\lib folder to the %AXISCLASSPATH%. Now I am trying to create the java classes using this cmd:
java -cp %AXISCLASSPATH% org.apache.wsdl.WSDL2JAVA http://myurl.com?wsdl
However I keep getting the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
WSDL2Java
Caused by: java.lang.ClassNotFoundException: org.apache.axis.wsdl.WSDL2Java
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: org.apache.axis.wsdl.WSDL2Java. Program will exit.
Can someone help me to get this working?
Add the jars to the classpath individually if you're using a Java version before 6. If you're using Java 6, see here if you want to use wildcards.
try
java -cp %AXISCLASSPATH% org.apache.wsdl.WSDL2Java http://myurl.com?wsdl
Class names are case sensitive
Login as eucalyptis and compile and it will find all of the jars - this took me forever to figure out!
package structure is wrong. Please use org.apache.axis.wsdl.WSDL2Java