File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Web service client problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web service client problem" Watch "Web service client problem" New topic
Author

Web service client problem

Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
Hello,

I'm having trouble with a Java web service which is a client of a .NET web service. The .NET web service runs on a remote server.
I created the client stubs using the "New Web Service Client" wizard of Eclipse. In the configuration section of the wizard I choose "Glassfish v2.1 Java EE 5" for the server, and "Apache Axis" for the web service runtime. The client stubs are generated from the WSDL successfully. Doing web service calls by running my Java web service from within Eclipse (using code generated by wsgen) works correctly. Also, when I run the web service on a Glassfish v2.1 server running locally on my PC, it also works correctly. However, when I deploy the web service on a Glassfish v2.1 server running on our remote server, a web service call fails with the following exception:



The web method being called here is the method. I think the interesting part of this exception stack trace is "".

As far as I know this must be caused by an exception thrown within the initializer block of the class.
What could be going wrong here? What must I do to get the web service calls to work on the remote Glassfish server?

Thanks in advance.
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
I'm having trouble with a Java web service which is a client of a .NET web service. The .NET web service runs on a remote server.
I created the client stubs using the "New Web Service Client" wizard of Eclipse.
In the configuration section of the wizard I choose "Glassfish v2.1 Java EE 5" for the server,
and "Apache Axis" for the web service runtime. The client stubs are generated from the WSDL successfully.
Doing web service calls by running my Java web service from within Eclipse (using code generated by wsgen) works correctly.
Also, when I run the web service on a Glassfish v2.1 server running locally on my PC, it also works correctly.
However, when I deploy the web service on a Glassfish v2.1 server running on our remote server,
a web service call fails with the following exception:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis.MessageContext
at org.apache.axis.AxisFault.setFaultCodeAsString(AxisFault.java:422) at org.apache.axis.AxisFault.(AxisFault.java:228)



Hi. Here is a guess If the client works fine locally, it is probably because you have setup axis.jar (which contains org.apache.axis.MessageContext) in the classpath.
And for the same reason, it works correctly in glassfish locally.
But on the remote server, axis.jar is not in the classpath.
Have you looked at this Axis-on-NetBeans tutorial?
Specifically, this section: Setting Up Axis2 Options for GlassFish.
If you are using Axis1, the this link might help.
Somehow, you need to put the axis jar in a location where it can be found.
Usually, this would be in a WEB-INF/lib or similar directory.

Hope that helps.
Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
Actually, Eclipse's "New Web Service Client" wizard automatically includes axis.jar and all other required libraries in the project under Web App Libraries, which is included when exporting to a WAR-file.
I did find a solution though. I installed Eclipse Web Tools onto Eclipse (wtp-R-3.1.2-20100211202452.zip and xsd-runtime-2.5.0.zip), recreated the web service client artifacts and viola! It be working!
It still remains a mystery to me though why it previously worked on my local GlassFish, but not on our server's. The server runs Linux while I run Windows - maybe it's got something to do with that.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I feel that leaving Axis out of the picture and using either the web service capabilities in JavaSE 1.6 (provided that you use it, of course) or the Metro web service stack present in GlassFish will simplify things.
Use wsimport from either the JDK 1.6 or from GlassFish to create client artifacts and then deploy the client to GlassFish, as a dynamic/regular web application.
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web service client problem
 
Similar Threads
Clients of Stateful Web Services on Ivan A Krizsan's notes
Passing Files in Web Services
Getting Exeption while calling web service from registry
SAAJ - Empty SOAP Response / Null Pointer Exception
Java Webservice problem (Array)