Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-03-22
21
Medium Priority
?
2,078 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
  • 10
  • 6
  • 4
20 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

578 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