?
Solved

Exception in thread "main" java.lang.NoClassDefFoundError: NHLServiceClient (wrong name

Posted on 2005-03-22
21
Medium Priority
?
2,053 Views
Last Modified: 2008-02-01
Hi all,

Im following a tutorial at http://javaboutique.internet.com/tutorials/Axis/ to create a web service with java and axis.

The client compiled ok but now i receive an error when i try to run it

C:\JavaStuff>java NHLServiceClient
Exception in thread "main" java.lang.NoClassDefFoundError: NHLServiceClient (wro
ng name: hansen/playground/NHLServiceClient)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Its say something about hansen/plaground is not valid. I can't find any reference to this package in axis but it is included on the tutorial site.

The first few lines of my code are:

package hansen.playground;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

My classpath is:

SET CLASSPATH=C:\JavaStuff;C:\Program Files\Apache Group\Tomcat 4.1
\webapps\axis\WEB-INF\lib\axis.jar;C:\Program Files\Apache Group\Tomcat 4.1\weba
pps\axis\WEB-INF\lib\commons-logging.jar;C:\Program Files\Apache Group\Tomcat 4.
1\webapps\axis\WEB-INF\lib\commons-discovery.jar;C:\Program Files\Apache Group\T
omcat 4.1\webapps\axis\WEB-INF\lib\saaj.jar;C:\Program Files\Apache Group\Tomcat
 4.1\webapps\axis\WEB-INF\lib\wsdl4j.jar;C:\Program Files\Apache Group\Tomcat 4.
1\webapps\axis\WEB-INF\lib\jaxrpc.jar

Anyone know whats up?

0
Comment
Question by:act1ve
[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
  • 10
  • 6
  • 4
21 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 13601389
>> The first few lines of my code are:
>> package hansen.playground;

Why is that if it is your code?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601399
try

java hansen.playground.NHLServiceClient
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601431
NHLServiceClient.java should be in

C:\JavaStuff\hansen\playground

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:zzynx
ID: 13601432
That tutorial is written by Hansen.
He included that tiny test program into a package called hansen.playground
You don't need that.

Try with removing the line:
>> package hansen.playground;
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601460
If you *can* ignore packages then you can delete the package declarations, yes
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601475
>>then you can delete the package declarations

(Although it's a blunt instrument for classpath problem solution, and will teach you nothing ;-))
0
 

Author Comment

by:act1ve
ID: 13601485
I removed the line and it compiled ok again, but i get the following error now:

C:\JavaStuff>java NHLServiceClient
22-Mar-2005 14:40:44 org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and javax
.mail.internet.MimeMultipart). Attachment support is disabled.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at NHLServiceClient.main(NHLServiceClient.java:17)

Any ideas? Thanks for your help
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601524
You need to place activation.jar and mail.jar in your jre/lib/ext directory
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601544
You may need to install JavaMail:

http://java.sun.com/products/javamail/downloads/
0
 

Author Comment

by:act1ve
ID: 13601577
Thanks,

Is there anything i can remove from the code below to not have to download java mail?

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

import java.net.*;

public class NHLServiceClient {
   public static void main(String [] args) throws Exception {
       
       Service service = new Service();
       Call call = (Call)service.createCall();

       String endpoint = "http://localhost:8080/axis/NHLService.jws";
       call.setTargetEndpointAddress(new URL(endpoint));
       call.setOperationName(new QName("getCurrentPosition"));

       String division = args[0];
       String team = args[1];
       String position =
         (String)call.invoke(new Object [] {new String(division), new

String(team)});
       
       System.out.println("Got result : " + position);
   }
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601646
It looks like the web service itself may be using it. Is it something to do with mail?
0
 

Author Comment

by:act1ve
ID: 13601669
This is the code for the web service:

import java.util.*;

public class NHLService {
  HashMap standings = new HashMap();
 
  public NHLService() {
    // NHL - part of the standings as per 04/07/2002
    standings.put("atlantic/philadelphia", "1");
    standings.put("atlantic/ny islanders", "2");
    standings.put("atlantic/new jersey", "3");
    standings.put("central/detroit", "1");
    standings.put("central/chicago", "2");
    standings.put("central/st.louis", "3");
  }  
 
  public String getCurrentPosition(String division, String team) {
    String p = (String)standings.get(division + '/' + team);
    return (p == null) ? "Team not found" : p;
  }  
}

Just simply displays the team and position from what i can see?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601743
Actually that's only a warning. You need to pass the division and team as parameters on the command line


java NHLService division team
0
 

Author Comment

by:act1ve
ID: 13601779
C:\JavaStuff>java NHLServiceClient central detroit
22-Mar-2005 15:00:28 org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and javax
.mail.internet.MimeMultipart). Attachment support is disabled.
Got result : 1

Worked, displayed the result as 1? :)

Do you know why it says attachment support is disabled, is there anyway of getting rid of that error altogether?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13601805
>>Do you know why it says attachment support is disabled

Because JavaMail is not installed. Installing it would shift the warning. It can be ignored for now.
0
 

Author Comment

by:act1ve
ID: 13601814
Thanks a lot for all your help :)
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1200 total points
ID: 13601841
If you have taken the sledgehammer to it and deleted the package declaration then this question's been partly answered by zzynx so you should credit him too points-wise ;-)
0
 
LVL 37

Accepted Solution

by:
zzynx earned 800 total points
ID: 13601852
I expected my comment telling you to remove that package line to be an assisted answer
0
 

Author Comment

by:act1ve
ID: 13601886
Yep no problem, sorry for that, I will post in community support now regarding a point split
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13601968
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

770 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