Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null Pointer Exception in WSDServiceFactory - Apache CXF libs

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.

like image 974
Robert Avatar asked Jan 26 '26 14:01

Robert


1 Answers

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'
  }
}
like image 141
Oleg T Avatar answered Jan 29 '26 04:01

Oleg T



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!