views:

278

answers:

3

Hi.

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?

+1  A: 

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?

Jon Skeet
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
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
OK, I'll try to deploy the service on my server. What tool(s) do you prefer for debugging?
Ezombort
No luck deploying the service to my server, still the same error.
Ezombort
So having deployed the service, where is TestClass in relation to the web service? (I use Eclipse for debugging, btw.)
Jon Skeet
I have to admit I'm on thin ice here hehe. I just exported the web service as WAR and deployed it in Tomcat manager. I kinda expected the WAR file to include dependencies like that?
Ezombort
+1  A: 

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

Shawn
Nice, thanks. I'll try it.
Ezombort
+1  A: 

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.

Thorbjørn Ravn Andersen
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
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
No I was not aware of that, I just added the project to the Preferences -> Java Build Path settings. Thanks a lot!
Ezombort