3
votes

I have an problem with my code. The WSDL file was parsed by wsdl2java from apache cxf. Now I'm trying to get connection with web service but still I'm getting null pointer exception.

Exception in thread "main" java.lang.NullPointerException
        at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
        at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:97)
        at javax.xml.ws.Service.<init>(Service.java:56)...

The url address is pointing to place from where I have downloaded the WSDL file. For building jar I'm using Maven with dependencies such as:

  • jaxws-api
  • cxf-rt-transports-http
  • cxf-rt-frontend-jaxws
  • cxf-rt-bindings-soap

jar with deps is created by maven-assembly-plugin

For sure the wsdl file exists there because it have been downloaded from there.

Any suggestions? Thanks for any help.

BTW. It's not duplicated question any of solution which I have found does not work for me.

3

3 Answers

3
votes

I ran into the same issue using shadowJar in gradle. The solution is to explicitly merge bus-extensions.txt service files in the META-INF/cxf/ directory:

shadowJar {
  archiveName = 'application.jar'
  mergeServiceFiles{
    path='META-INF/cxf'
  }
}
1
votes

Instead using maven-assembly-plugin when deploying Java app that depends on Apache CXF libs, I have used maven-dependency-plugin with goal set to copy-dependencies. That will not produce single JAR, but will copy all required JARs into target/ folder. It is then easy to put them all in class path and start Java app.

0
votes

The soloution is quite simple, I just changed the version of Apache CXF lib to older one, and it works. So probably I had a problem in my configuration or Apache CXF have a bug.

So as a solution just check the older version of provided lib.