users@jax-ws.java.net

Re: NullPointerException when running client

From: kathy walsh <Kathleen.Walsh_at_Sun.COM>
Date: Wed, 28 Jun 2006 10:18:49 -0400

Daniel,

What version of jaxws are you using with your program and where did you
get it from?

I suspect that there is a difference in the runtime you are using of
jaxws that comes with java 6
versus what you are using with java 5.

In your program try creating the service by instantiating the
service class.

HelloService helloService = new HelloService();

HelloPort hello = helloService.getHelloPort();


Please let us know if you have more problems-

Thanks,
Kathy





Daniel Robinson wrote:

>
> Hello all,
>
> I have got a simple WebService running. I have successfully called it
> from Perl.
>
> I have also sucessfully called it using a java client running in Java 6.
>
> However I now need to get this working in Java 5. I am starting by the
> client side of things. This is where I get the NullPointerException. I
> have had a look through the source code and am unsur how this could work.
>
> This is the trace I get :
>
> java.lang.NullPointerException
> at
> com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:352)
> at com.sun.xml.ws.client.WSServiceDelegate.getPort
> (WSServiceDelegate.java:242)
> at javax.xml.ws.Service.getPort(Service.java:94)
> at
> jet.container.managers.webservicesclient.WebServicesClientManager$1.run(WebServicesClientManager.java:101)
> at java.security.AccessController.doPrivileged (Native Method)
> at
> jet.container.managers.webservicesclient.WebServicesClientManager.getWebServiceInstance(WebServicesClientManager.java:96)
> at
> jet.container.managers.webservicesclient.WebServicesClientManager.invoke
> (WebServicesClientManager.java:77)
> at
> jet.container.exchange.AbstractContext.invoke(AbstractContext.java:300)
> at
> jet.container.managers.webservicesclient.WebServicesClientManagerContextImpl.getWebServiceInstance
> (WebServicesClientManagerContextImpl.java:28)
> at
> be.inveo.jet.test.webservices.WebServiceTestNut.run(WebServiceTestNut.java:92)
> at java.lang.Thread.run(Thread.java:595)
>
>
> AS you can see the problem starts in the getPort method. This is how
> things are called in the client :
>
>
> private Object getWebServiceInstance(final Class sei, final URL
> wsdlLocation, final String namespaceURI, final String serviceName,
> final String portName) throws ConnectException {
> final QName serviceQName = new QName(namespaceURI, serviceName);
>
> Object obj = null;
> try {
> obj = AccessController.doPrivileged(new
> PrivilegedExceptionAction<Object>() {
> public Object run() throws Exception {
> Service service = Service.create(wsdlLocation,
> serviceQName);
>
> QName portQName = new QName(namespaceURI, portName);
> Object proxy = service.getPort(portQName, sei);
> BindingProvider bp = (BindingProvider) proxy;
>
> Map<String, Object> context = bp.getRequestContext();
>
> context.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
>
> return proxy;
> }
> });
> } catch (PrivilegedActionException pae) {
> Throwable t = pae.getCause();
> if (t instanceof WebServiceException) {
> WebServiceException wse = (WebServiceException) t;
> throw wse;
> }
> if (t instanceof ConnectException) {
> ConnectException ce = (ConnectException) t;
> throw ce;
> }
> }
>
>
> return obj;
> }
>
>
>
> When I run this through the debugger I can see that the problem is
> that the seiContext in the WSServiceDelegate is empty. This is the
> case as the addSEI() method is not called in the constructor as the
> serviceClass == Service.class.
>
> It is not clear where I have gone wrong (though I am certain I have
> gone wrong somewhere). The NullPointerException is not much help however.
>
> Does anybody with a better understanding of the inner workings of
> JAX-WS know what is going on here?
>
> Thank you in advance for any help.
>
> Daniel
>
>
>
>
>
>
>
>