• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Null Pointer Exception encountered when accessing a simple Hello webservice

Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 java.net.URL(endpoint) );

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: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultString: java.lang.NullPointerException
at org.apache.axis.message.MessageElement.addTextNode(MessageElement.java:1396)
at org.apache.axis.message.SOAPHandler.addTextNode(SOAPHandler.java:148)
at org.apache.axis.message.SOAPHandler.endElement(SOAPHandler.java:112)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at weblogic.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:585)
at weblogic.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(XMLNamespaceBinder.java:898)
at weblogic.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:644)
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(DTDConfiguration.java:525)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:138)

at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)

at samples.userguide.example1.TestClient.main(TestClient.java:52)

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

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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
author and cow tipper
Posts: 5009
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic