Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

java.lang.NoClassDefFoundError

Posted on 2004-03-30
24
Medium Priority
?
464 Views
Last Modified: 2007-12-19
Hi experts, I get this error when I try to execute a java file. Thanks

D:\DS\dsSoapLab>java gmit.CalcClient
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/utils
/Options
        at gmit.CalcClient.main(CalcClient.java:12)

the java file:
package gmit;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import javax.xml.rpc.ParameterMode;

public class CalcClient{
      public static void main(String [] args) throws Exception{
            Options options = new Options(args);

            String endpoint = "http://localhost:8080/axis/Calculator.jws";

            // Do argument checking
             args = options.getRemainingArgs();

             if (args == null || args.length != 3){
                  System.err.println("Usage: CalcClient <add|subtract arg1 arg2");
                 return;
             }

             String method = args[0];
             if (!(method.equals("add") || method.equals("subtract"))) {
                  System.err.println("Usage: CalcClient <add|subtract arg1 arg2");
                  return;
             }

            // Make the call
             Integer i1 = new Integer(args[1]);
             Integer i2 = new Integer(args[2]);

             Service service = new Service();
             Call call = (Call) service.createCall();

        call.setTargetEndpointAddress(new java.net.URL(endpoint));
        call.setOperationName( method );
        call.addParameter("op1", XMLType.XSD_INT, ParameterMode.IN);
        call.addParameter("op2", XMLType.XSD_INT, ParameterMode.IN);
        call.setReturnType(XMLType.XSD_INT);

        Integer ret = (Integer) call.invoke( new Object [] { i1, i2 });

        System.out.println("Got result : " + ret);
      }
}
0
Comment
Question by:Ronayne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 11
24 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10715149
Sounds like the Apache Axis libraries not in classpath. Place jars in all lib\ext directories
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10715271
Type:
D:\DS\dsSoapLab>java -cp .;<location of axis.jar> gmit.CalcClient
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10715272
More particularly, your runtime classpath does not correspond to your compile time one. If you want to keep the number of copies of these jars down to a minimum, you can avoid following my first suggestion but instead, you'll have to set the runtime classpath to the same one that was used at compile time.
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 86

Expert Comment

by:CEHJ
ID: 10715282
Here is some general info on the classpath:

http://mindprod.com/jgloss/classpath.html
0
 

Author Comment

by:Ronayne
ID: 10715990
This is my classpath

C:\>set classpath
CLASSPATH=.;C:\j2sdk1.4.0_03\lib;c:\rmi\gmit;C:\Program Files\Apache Group\Tomca
t 4.1\server\lib\catalina.jar;D:\xml-xindice-1.0\java\lib\xindice.jar;c:\castor-
0.9.5.2.jar;d:\DS\dsSoapLab\gmit
0
 

Author Comment

by:Ronayne
ID: 10715991

I have axis.jar in my jre/lib/ext folder in my jdk
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716032
>>d:\DS\dsSoapLab\gmit

That one's not actually right in fact. Should be

d:\DS\dsSoapLab

But forget that for the moment. Before running from that directory , type

set classpath=

and try it again
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716042
>>and try it again

Meaning running, not compiling
0
 

Author Comment

by:Ronayne
ID: 10716113

I tried that and I got the same error
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716144
Now there's no classpath, run this program with the parameter "java.ext.dirs" and tell me the output:

public class Props {
      
      public static void main(String[] args) {
            if (args.length > 0) {
                  for (int i = 0; i < args.length; i++) {
                        System.out.println(System.getProperty(args[0]));
                  }
            }
            else {
                  System.getProperties().list(System.out);
            }
      }
}
0
 

Author Comment

by:Ronayne
ID: 10716152

I removed the classpath from my environmental variable settings but still the same error
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716183
You shouldn't have done that really, but no matter - you posted it here so you can restore it. You can unset/set the classpath per instance of a command window, so there's no need to do that. Anyway, leave it empty for the moment and compile and run the above.
0
 

Author Comment

by:Ronayne
ID: 10716188

I ran that program and got this:
c:\program files\java\j2re1.4.0_03\lib\ext
0
 

Author Comment

by:Ronayne
ID: 10716206

i saved a copy in notepad anyway, i wouldnt be so daft as to stop myself from undoing the changes I make
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716210
OK. That's where that Axis jar should be
0
 

Author Comment

by:Ronayne
ID: 10716345

that is brilliant, thank you very much, how does your code work?
0
 

Author Comment

by:Ronayne
ID: 10716348

I thought jdk automatically looks in jre/lib/ext for jar files?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716370
>>I thought jdk automatically looks in jre/lib/ext for jar files?

Yes it does. Your axis.jar must not have been there originally
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 10716391
Since you already have a classpath set, you may as well simply add a path to the jar to it, or you may find you have to put another copy in C:\j2sdk1.4.0_03\lib\ext if you want to compile against it - it's up to you though.
0
 

Author Comment

by:Ronayne
ID: 10716444

my axis jar file was always in jre/lib/ext, even when it threw my original error, thats why im confused. Id just like to know why it did'nt work  
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716558
I'm not sure at the moment. Keep the jar where it is and reset the classpath (in environment variables) to *exactly* what it was before and we'll see if we can break it again ;-)
0
 

Author Comment

by:Ronayne
ID: 10716674

ive done that and everything is working fine now, just one of those things I geuss.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10716721
OK - we'll let it ride ;-)
0
 

Author Comment

by:Ronayne
ID: 10716835
Fine by me
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question