hi,all:
ClientProxy throws NullPointerException when invoking its invoke();
java version : jdk1.6.0_30
cxf version :2.6.2 ,2.7.0,2.7.3
I debug the code and find the ClientProxy.finalize() closes the bus ,so the
bus is null ,then when the ClientImpl to invoke the method doInvoke(),it
throws NullPointerException
the exception is:
DEBUG org.apache.cxf.phase.PhaseInterceptorChain 2013-02-21 22:36:23 -
Invoking handleFault on interceptor
org.apache.cxf.jaxws.interceptors.HolderOutInterceptor@3468f4
DEBUG org.apache.cxf.phase.PhaseInterceptorChain 2013-02-21 22:36:23 -
Invoking handleFault on interceptor
org.apache.cxf.ws.policy.PolicyOutInterceptor@633d51
WARN org.apache.cxf.phase.PhaseInterceptorChain 2013-02-21 22:36:23 -
Interceptor for
{http://server.hw.demo/}HelloWorld#{http://server.hw.demo/}sleep has thrown
exception, unwinding now
java.lang.NullPointerException: NullPointerException invoking
http://localhost:9000/Hello: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1338)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1327)
at
org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:339)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:325)
at demo.wsdl2java.Demo.invokeByClientProxy(Demo.java:41)
at demo.wsdl2java.Demo.main(Demo.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.NullPointerException
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:719)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1592)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1490)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
... 17 more
java.lang.NullPointerException
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:368)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:339)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:325)
at demo.wsdl2java.Demo.invokeByClientProxy(Demo.java:41)
at demo.wsdl2java.Demo.main(Demo.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
The Sever works fine.
step1: To run the class demo.hw.server.Server.java
public class Server {
protected Server() throws Exception {
HelloWorldImpl helloworldImpl = new HelloWorldImpl();
ServerFactoryBean svrFactory = new ServerFactoryBean();
svrFactory.setServiceClass(HelloWorld.class);
svrFactory.setAddress("http://localhost:9000/Hello");
svrFactory.setServiceBean(helloworldImpl);
//svrFactory.getServiceFactory().setDataBinding(new
AegisDatabinding());
svrFactory.create();
}
public static void main(String args[]) throws Exception {
new Server();
System.out.println("Server ready...");
Thread.sleep(500 * 60 * 1000);
System.out.println("Server exiting");
System.exit(0);
}
}
But the client failed,it throws a NullPointerException
step2: to run the client demo.wsdl2java.Demo.java,it throws a
NullPointerException
public class Demo {
protected org.apache.cxf.endpoint.Client initClient() {
int connectTimeout=10;
int receiveTimeout=60;
HelloWorld helloWorld = new HelloWorld();
HelloWorldPortType port = helloWorld.getHelloWorldPort()
;
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(port);
// HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
// HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
// //httpClientPolicy.setConnectionTimeout(connectTimeout);
// httpClientPolicy.setAllowChunking(false);
// //httpClientPolicy.setReceiveTimeout(receiveTimeout);
// httpConduit.setClient(httpClientPolicy);
// client.getInInterceptors().add(new LoggingInInterceptor());
// client.getOutInterceptors().add(new LoggingOutInterceptor());
return client;
}
public void invokeByClientProxy(){
System.out.println("invoke initClient...");
Client client= this.initClient();
System.out.println("invoke sleep...");
Object[] result= new Object[0];
try {
result = client.invoke("sleep",0L);
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
}
client.destroy();
System.out.println("PRINT RESULT...");
for(int i=0;i<result.length;i++){
System.out.println(result[i]);
}
}
public void invoke(){
QName SERVICE_NAME = new QName("http://server.hw.demo/",
"HelloWorld");
URL wsdlURL = HelloWorld.WSDL_LOCATION;
HelloWorld ss = new HelloWorld(wsdlURL, SERVICE_NAME);
HelloWorldPortType port = ss.getHelloWorldPort();
{
System.out.println("Invoking sleep...");
long _sleep_arg0 = 0;//60*1000+200;
java.lang.String _sleep__return = port.sleep(_sleep_arg0);
System.out.println("sleep.result=" + _sleep__return);
}
}
public static void main(String[] args) throws Exception {
Demo demo = new Demo();
demo.invokeByClientProxy();
// demo.invoke();
// Thread.sleep(100000);
}
}
the source code is :
<nabble_a href="cxf-nullpoint-demo.rar">cxf-nullpoint-demo.rar
--
View this message in context:
http://cxf.547215.n5.nabble.com/ClientProxy-throws-NullPointerException-when-invoking-its-invoke-tp5723532.html
Sent from the cxf-user mailing list archive at Nabble.com.