File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes java.lang.NoClassDefFound When Running Samples - New to Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "java.lang.NoClassDefFound When Running Samples - New to Java" Watch "java.lang.NoClassDefFound When Running Samples - New to Java" New topic
Author

java.lang.NoClassDefFound When Running Samples - New to Java

Lenin_Tony
Greenhorn

Joined: Sep 23, 2003
Posts: 9
Hi,
first very sorry I posted this to the beginners java group as it appears to be strightforward. However I though someone from this forum may be more specific with a resolution.

I am sorry if this has been asked a thousand times but....

1. I have installed AXIS 1.3 and all seems well i.e. I can view the happyaxis.jsp page and all the relevant jars are there.

2. As a post install activity I tried to run some of the web samples provided in the "Consuming Web Services with AXIS" section of the users guide. (samples\userguide\example1\TestClient.class) i.e. java samples.userguide.example1.TestClient

3. When I do this I get the "java.lang.NoClassDefFound" error.

4. I had assumed this meant the environment was looking for something it couldn't find, so as part of the java command I added the "-cp" switch followed by all the jar files referenced in the AXISCLASSPATH path i.e. axis.jar, activation.jar, ........

5. Same Error

Can someone inform me of what could be mising?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
The error should state which class it's missing - that's a crucial piece of information for investigating this problem. Could it be that it's actually the TestClient class that is not in the classpath?


Ping & DNS - my free Android networking tools app
Lenin_Tony
Greenhorn

Joined: Sep 23, 2003
Posts: 9
Not sure what you mean? Do you mean I should add the location of my compiled class into the class path?

The exact error I get from executing from command line is

Exception in thread main java.lang.NoclassDefFoundError: samples/userguide/example1/TestClient

As I say any help greatly appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
Yes, the classpath should contain all (or most) of the Axis jar files, as well as the TestClient class. Most likely that means that you need to add %TOMCAT_HOME%/webapps/axis/WEB-INF/classes to your classpath.
Lenin_Tony
Greenhorn

Joined: Sep 23, 2003
Posts: 9
Thanks again. However the problem persists. Here is the exact syntax of what I am trying to execute. I am executing here from the location of the .class file.

E:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\classes\samples\userguide\example1>java -cp ".;E:\Program Files\Java\AXIS\axis-1_3\lib\axis.jar;E:\Program Files\Java\AXIS\axis-1_3\lib\commons-discovery.jar; E:\Program Files\Java\AXIS\axis-1_3\lib\commons-logging.jar;%AXIS_LIB%\jaxrpc.jar;E:\Program Files\Java\AXIS\axis-1_3\lib\saaj.jar;E:\Program Files\Java\AXIS\axis-1_3\lib\log4j-1.2.8.jar;E:\Program Files\Java\AXIS\axis-1_3\lib\xml-apis.jar;E:\Program Files\Java\AXIS\axis-1_3\lib\xercesImpl.jar"
samples.userguide.example1.TestClient
Exception in thread "main" java.lang.NoClassDefFoundError: samples/userguide/example1/TestClient
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42596
    
  65
Do a "cd ..\..\.." and then execute the very same command. You should read up on the concept of Java packages and the concept of classpaths - then you'll understand what's going on.
Lenin_Tony
Greenhorn

Joined: Sep 23, 2003
Posts: 9
You're right I should, and will.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NoClassDefFound When Running Samples - New to Java