Link to home
Start Free TrialLog in
Avatar of newone2011
newone2011

asked on

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/wsdl/WSDL2

I keep getting this error even though I have all the classes. I am trying to run the command:

java -classpath "wsdl2java
.jar;wsdl4j.jar;axis.jar;axis-ant.jar;saaj.jar;junit-4.0.jar;jaxrpc.jar;log4j-1.
2.8.jar;commons-logging.jar;commons-discovery.jar" org.apache.wsdl.WSDL2Java cls
Test.wsdl
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/wsdl/WSDL2
Java
Caused by: java.lang.ClassNotFoundException: org.apache.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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.apache.wsdl.WSDL2Java.  Program will exit.
Also here are the files in my dir:

<DIR>          .
   <DIR>          ..
        385,010 axis-ant.jar
        1,235,721 axis.jar

          25,187 Test.wsdl
  <DIR>          com
          71,442 commons-discovery.jar
          31,605 commons-logging.jar
          35,759 jaxrpc.jar
         105,601 junit-4.0.jar
          352,668 log4j-1.2.8.jar
    <DIR>          META-INF
   <DIR>          org
          18,501 saaj.jar

   <DIR>          wsdl2java
          5,140 WSDL2Java.class
            7,803 wsdl2java.jar
         113,853 wsdl4j.jar
Avatar of for_yan
for_yan
Flag of United States of America image

in waht directory are you issiuning this command?it looks like all your jars are in diffenernt folders but you don;'t mention those folders in your command line in classpath string
put all your jars in one folder and in the same folder issue the above command

when you say

jav -cp "wsdl2java.jar;commons-logging.jar" ..
it assumes that these jars are right in this folder where you excute your command
You either need to put them all in one folder or specify the folders, like:

java -cp "wsdl2java\wsdl2java.jar;wsdl2java\wsdl4j.jar;com\commons-discovery.jar;..."

assuming that you are in the folder one level higher than wsdl2java and com folders
Avatar of newone2011
newone2011

ASKER

for_yan my jars are all in the same folder from where I am running this command. That's why I am surprised as I to why I am still getting this error.
But you DIR printout shows them in different folders ? Is this old location ?

So you have them all in one folder and you are trying to execute command in the same folder?
It also shows some strange end of lines inside your command - are they really there?
I am removed all dirs to avoid any confusion. Here is the listing:

02/01/2012  02:53 PM    <DIR>          .
02/01/2012  02:53 PM    <DIR>          ..
08/22/2009  11:17 AM           385,010 axis-ant.jar
08/22/2009  11:17 AM         1,235,721 axis.jar
02/01/2012  01:33 PM            25,187 Test.wsdl
08/22/2009  11:17 AM            71,442 commons-discovery.jar
08/22/2009  11:17 AM            31,605 commons-logging.jar
08/22/2009  11:17 AM            35,759 jaxrpc.jar
02/15/2009  11:34 PM           105,601 junit-4.0.jar
08/22/2009  11:17 AM           352,668 log4j-1.2.8.jar
08/22/2009  11:17 AM            18,501 saaj.jar
06/13/2009  09:19 AM             5,140 WSDL2Java.class
08/22/2009  11:17 AM             7,803 wsdl2java.jar
08/22/2009  11:17 AM           113,853 wsdl4j.jar

I run it again: (cleaned up the char)
java -classpath "wsdl2java
.jar;wsdl4j.jar;axis.jar;axis-ant.jar;saaj.jar;junit-4.0.jar;jaxrpc.jar;log4j-1.
2.8.jar;commons-logging.jar;commons-discovery.jar" org.apache.wsdl.WSDL2Java
Test.wsdl

I get the same error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/wsdl/WSDL2
Java
Caused by: java.lang.ClassNotFoundException: org.apache.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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.apache.wsdl.WSDL2Java.  Program will exit.
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Check your wsdl2java.jar - it should contain org.apache.axis.wsdl.WSDL2Java.class
in the appropriate folderr

You can just make a copy to wsdl2java.zip and inspect this zip file with winzip

Once it has this file in tha appropriate folder - it should find it
You know when I go to findJar.com and type

org.apache.wsdl.WSDL2Java

I find nothing, but when i type

org.apache.axis.wsdl.WSDL2Java


then I find a lot

Maybe you need

org.apache.axis.wsdl.WSDL2Java

after all
Avatar of CEHJ
With something of this complexity, you'd find it a lot easier to run/build with Ant
This is resolved. The problem was here:
java -classpath "axis.jar;
axis-ant.jar;wsdl2java.jar;wsdl4j.jar;saaj.jar;junit-4.0.jar;jaxrpc.jar;log4j-1.
2.8.jar;commons-logging.jar;commons-discovery.jar" org.apache.axis.wsdl.WSDL2Jav
a
Test.wsdl

IT was org.apache.axis.wsdl  and not org.apache.wsdl   It was part of axis.jar.

Meanwhile could you also let me know on the ant solution using may be eclipse.  I will award the points.
the ant solution using may be eclipse

afaicr Eclipse doesn't mix too well with Ant. I use Ant 'bare'
Not complete