[ 
https://issues.apache.org/jira/browse/CXF-6070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14188710#comment-14188710
 ] 

Daniel Kulp commented on CXF-6070:
----------------------------------


This is working kind of as designed.   If you use a "*Service" object to create 
a proxy (service.getXYZ() calls), you are expected to use that proxy for making 
the calls to the service.  Not dig into the proxy and use the client object 
directly for the calls.  The access to the client is there to allow configuring 
of things prior to making the calls.

The issue is that proxy that is generated is being garbage collected (since you 
aren't using it) which is causing it to cleanup and release a bunch of things 
including the HTTP conduits, the request/response contexts, etc...   

If you need just a Client object, use the JaxWsClientFactoryBean.

That said, with 3.0.x, the proxy returned from the service.getXXX() calls 
implements the Client interface directly and thus could be used as above 
without the call to ClientProxy.getClient and using a direct cast instead.   
That would keep the proxy from being garbage collected.

> NPE while calling a webservice using a clientproxy
> --------------------------------------------------
>
>                 Key: CXF-6070
>                 URL: https://issues.apache.org/jira/browse/CXF-6070
>             Project: CXF
>          Issue Type: Test
>          Components: Simple Frontend
>    Affects Versions: 2.7.12, 3.0.1, 2.7.13, 2.6.16
>            Reporter: Varun
>
> We have implemented a webservice client using apache-cxf .
> When calling a webservice through a ClientProxy, for some reason there is an 
> exception 
>  [main] INFO org.apache.cxf.service.factory.ReflectionServiceFactoryBean - 
> Creating Service 
> [main] WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for has 
> thrown exception, unwinding now
> java.lang.NullPointerException: NullPointerException invoking 
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
>       at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1347)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1336)
>       at 
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
>       at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
>       at 
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
>       at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
>       at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:570)
>       at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:479)
>       at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382)
>       at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335)
>       at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355)
>       at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:341)
> Caused by: java.lang.NullPointerException
>       at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:764)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1515)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1318)
>       ... 12 more
> Exception in thread "main" java.lang.NullPointerException
>       at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:339)
> ------------------------------------------------------------------------------------------------------------
> 1.    Testing using a standalone java program.
> 2.    This doesn’t happen when apache cxf version 2.4 is used .
> 3.    When upgraded the version to 2.6 and above ,we are facing this issue.
> Code  used to invoke the webservice is :
> TestService service=new TestService();
>  Client client = ClientProxy.getClient(service.get*);
>  Map<String, Object> requestContext = client.getRequestContext();
>  requestContext.put(org.apache.cxf.message.Message.MAINTAIN_SESSION, 
> Boolean.TRUE); 
>  requestContext.put(ENDPOINT_ADDRESS_PROPERTY,faxUrl); 
>  Object[] logOnResp= client.invoke(“webservice”,param1,param2,param3,param4);
>       



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to