File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Null Pointer Exception encountered when accessing a simple Hello webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Null Pointer Exception encountered when accessing a simple Hello webservice" Watch "Null Pointer Exception encountered when accessing a simple Hello webservice" New topic

Null Pointer Exception encountered when accessing a simple Hello webservice

kumari Jain
Ranch Hand

Joined: Jul 28, 2004
Posts: 44
Hi all,
I have installed Axis 1.4 ,Tomcat-4.1.34 ,jdk 1.4 to try out web services examples.
I'm trying to deploy and test a simple HelloService program.
This program has a method sayHello that takes a string parameter and returns a string result.

This is the web service
public class HelloService
public String sayHello(String name)
System.out.println("sayHelloTo(String name)");
return "Hello " + name + ", How are you doing?";

This is the client
public class TestClient
public static void main(String [] args)
String endpoint = "http://localhost:8080/axis/HelloService.jws";

Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new );

call.addParameter( "op1", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN );
call.setReturnType( org.apache.axis.Constants.XSD_STRING );

String ret = (String) call.invoke( new Object[] { "Hello!" } ); /* Line 52 : exception is thrown */

System.out.println("Sent 'Hello!', got '" + ret + "'");


When i run the client file which invokes the web service,i get the following NullPointerException.

faultCode: {}Server.userException
faultString: java.lang.NullPointerException
at org.apache.axis.message.MessageElement.addTextNode(
at org.apache.axis.message.SOAPHandler.addTextNode(
at org.apache.axis.message.SOAPHandler.endElement(
at org.apache.axis.encoding.DeserializationContext.endElement(
at weblogic.apache.xerces.parsers.AbstractSAXParser.endElement(
at weblogic.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(
at weblogic.apache.xerces.impl.XMLNamespaceBinder.endElement(
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndEle
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentCo
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocume
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(
at weblogic.apache.xerces.parsers.XMLParser.parse(
at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(
at weblogic.xml.jaxp.WebLogicXMLReader.parse(
at weblogic.xml.jaxp.RegistryXMLReader.parse(

at org.apache.axis.AxisFault.makeFault(
at org.apache.axis.transport.http.HTTPSender.invoke(
at org.apache.axis.strategies.InvocationStrategy.visit(
at org.apache.axis.SimpleChain.doVisiting(
at org.apache.axis.SimpleChain.invoke(
at org.apache.axis.client.AxisClient.invoke(
at org.apache.axis.client.Call.invokeEngine(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(

at samples.userguide.example1.TestClient.main(

Caused by: java.lang.NullPointerException
at org.apache.axis.message.MessageElement.addTextNode(
at org.apache.axis.message.SOAPHandler.addTextNode(

I checked the TCP monitor.It shows the string sent in the request soap message and the result string sent in the SOAP response.

If however i write another method that takes an integer as a parameter and returns an integer,there is no problem.The method successfully returns the integer result.

Can somebody give me a solution to this problem.
kumari Jain
Ranch Hand

Joined: Jul 28, 2004
Posts: 44
hi all

I have found out the cause of the problem.The classpath included webservices.jar.This was the jar file required for running webservices on weblogic.The problem was the presence of duplicate classes possibly of different versions in webservices.jar and axis jar files.

Hence once when webservices.jar was removed from classpath everything worked fine.I have found that many people had faced same problem but the solution was not put anywhere.Hope this post is useful for others.

Zoltan Gombosi

Joined: Oct 03, 2006
Posts: 1
I also found this same problem to occur if you are using the jrockit 1.4 JVM. Instead I switched to used the standard sun 1.4 JVM and this resolved the problem.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Thanks for the update.

So many people post problems, discover a solution, but don't update the post.

I have seen many, many people deal with this issue. Trust me, you've just helped out alot of people, and that's what a board like this is all about.


I agree. Here's the link:
subject: Null Pointer Exception encountered when accessing a simple Hello webservice
jQuery in Action, 3rd edition