Hello CXF users,
I tried using the logging handler from the CXF samples in my own test.
I get the following NPE when I run my client.
INFO: Creating Service {http://test.com}ws from class
com.test.cxf.HelloWorld
Exception in thread "main" java.lang.NullPointerException
at
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.buildHandlerChain(JaxWsProxyFactoryBean.java:134)
at
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.clientClientProxy(JaxWsProxyFactoryBean.java:82)
at
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:111)
at
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:93)
at com.test.cxf.Client.main(Client.java:35)
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:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Looking at the CXF source, it seems the resource manager is null when
trying to create the resource injector.
On the server side, my last few messages were:
Jul 9, 2008 11:46:08 AM org.apache.cxf.jaxws.handler.HandlerChainBuilder
buildHandlerChain
FINE: loading handler
Jul 9, 2008 11:46:08 AM org.apache.cxf.jaxws.handler.HandlerChainBuilder
buildHandlerChain
FINE: adding handler to chain: [EMAIL PROTECTED]
Server started at http://localhost:9999/hello
Here is my server code:
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setServiceClass(HelloWorld.class);
sf.getServiceFactory().setWrapped(true);
QName name = new QName("http://test.com", "ws", "");
sf.setServiceName(name);
sf.setAddress("http://localhost:9999/hello");
HelloWorld helloService = new HelloWorldImpl();
sf.getServiceFactory().setInvoker(new BeanInvoker(helloService));
org.apache.cxf.endpoint.Server server = sf.create();
String endpoint = server.getEndpoint().getEndpointInfo().getAddress();
System.out.println("Server started at " + endpoint);
Here is my client code:
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
proxyFactory.setServiceClass(HelloWorld.class);
proxyFactory.setAddress("http://localhost:9999/hello");
QName name = new QName("http://test.com", "ws", "");
proxyFactory.setServiceName(name);
Handler handler = new LoggingHandler();
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
proxyFactory.setHandlers(handlerChain);
HelloWorld hello = (HelloWorld) proxyFactory.create();
Both the service and interface has been annotated with:
@HandlerChain(file = "./handlers.xml")
And my handlers.xml:
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
<handler-chain>
<handler>
<handler-name>LoggingHandler</handler-name>
<handler-class>com.test.cxf.LoggingHandler</handler-class>
</handler>
</handler-chain>
</handler-chains>
Am I missing anything? Appreciate your help.
Thank you,
Arul