Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

I have an Axis (1.4) web service (running on Tomcat 6.0.20) that is working fine until I try to use any class from another project.

I have my web service project and another project containing business logic. I have added the business logic project as a project dependency/reference in my web service project.

package MyProject.services;
import BusinessLogic.Core.TestClass;

    public class MyServiceImpl implements MyProject.services.MyServiceImpl_PortType {

    public java.lang.String getServerStatus() throws java.rmi.RemoteException {
             //BusinessLogic.Core.TestClass core = new BusinessLogic.Core.TestClass();
             return "This is working fine!";
    }
}

When I invoke the method above, everything works fine. However, if I uncomment the line in getServerStatus(), I get a NoClassDefFoundException.

The code is ofcourse compiling fine and as far as I can see i have added all dependencies. The TestClass has only a constructor that prints "Hello" and has no other dependencies.

I'm relatively new to java web services so it is probably just a stupid mistake I have made. Do you have any ideàs?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

You say you have them in different projects. If this means WAR-files/folders inside Tomcat, then your problem could be that one web application cannot see any other web application directly (including classpath).

If not, then edit your question to be very specific about what you see and what you expect.

share|improve this answer
    
I mean different projects in Eclipse. I'm just adding a project reference, importing the namespace and using the class. This class is not found when I invoke the service. –  Ezombort Jul 17 '09 at 8:23
1  
You are aware of the Preferences -> Java EE Module Dependencies, which governs which components get deployed to the war file? Also 7zip allows easy jar/war/whatever introspection. I believe the class is not deployed. –  Thorbjørn Ravn Andersen Jul 17 '09 at 8:48
    
No I was not aware of that, I just added the project to the Preferences -> Java Build Path settings. Thanks a lot! –  Ezombort Jul 17 '09 at 8:54

You haven't said how you're building and deploying this. Is TestClass in a jar file somewhere? If so, where is the jar file in the deployed system, and how are your web service classes deployed?

share|improve this answer
    
I'm just testing locally, running Tomcat from Eclipse. TestClass is just in another project in the workspace, and I have added a reference to the BusinessLogic project in Eclipse (Jave Buil Path/Projects). The service itself is working fine, and I am able to access/invoke it from my .NET project as long as I'm not using the TestClass in my service implementation. –  Ezombort Jul 17 '09 at 6:56
    
You'll need to look at exactly how Tomcat is being run, and where TestClass ends up. Personally I've always preferred to debug Tomcat from a deployed perspective - i.e. do whatever packaging you'd do for production, then run a debugger against that. It means these issues are a problem if and only they'd be a problem in production. –  Jon Skeet Jul 17 '09 at 7:08
    
OK, I'll try to deploy the service on my server. What tool(s) do you prefer for debugging? –  Ezombort Jul 17 '09 at 7:18
    
No luck deploying the service to my server, still the same error. –  Ezombort Jul 17 '09 at 8:21
    
So having deployed the service, where is TestClass in relation to the web service? (I use Eclipse for debugging, btw.) –  Jon Skeet Jul 17 '09 at 8:26

This is not an answer to your question but you can use this free soapui

to look at the wsdl that is produced and call methods on the service. This means that you can test your service without compiling and deploying the stubs to a second test client (which you will have to do at a later stage)

Hope this helps

share|improve this answer
    
Nice, thanks. I'll try it. –  Ezombort Jul 17 '09 at 8:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.