Null Pointer Exception in WSDServiceFactory - Apache CXF libs

不问归期 提交于 2019-12-24 17:53:05

问题


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.


回答1:


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.




回答2:


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'
  }
}



回答3:


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.



来源:https://stackoverflow.com/questions/11428311/null-pointer-exception-in-wsdservicefactory-apache-cxf-libs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!