I am trying to build a WS client using Apache CXF 2.7.11. I created the sample classes using wsdl2java
tool. I have a Eclipse project with:
- all the code generated by wsdl2java
- all the jar files from /lib installed.
I am basically following this tutorial: http://cxf.apache.org/docs/developing-a-consumer.html
When I run the sample code created by wsdl2java
, I get this error:
Exception in thread "main" java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:101)
at javax.xml.ws.Service.<init>(Service.java:67)
at com.twinfield.Session.<init>(Session.java:46)
at com.twinfield.SessionSoap_SessionSoap_Client.main(SessionSoap_SessionSoap_Client.java:48)
Using the debugger, I found out that the null in question is caused by CXFBusImpl.getExtension(WSDLManager.class)
. Line 98 in WSDLServiceFactory.java reads:
definition = getBus().getExtension(WSDLManager.class).getDefinition(url);
I thought that the problem was with my wsdl location, but based on above that might not be the case? I have tried both local file and an URL as a value to the -wsdlLocation switch of wsdl2java
. (Currently I don't use that parameter at all)
Web searches turned up only some very old problems with version 2.0 and 2.4. There is a similar question here: Null Pointer Exception in WSDServiceFactory - Apache CXF libs , but the answer was just to use an old version...
Could this be a configuration problem? Do I need any configuration files in my project?