Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Lenin_Tony
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Lenin_Tony
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right I should, and will.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic