ServiceConstructionException when creating a CXF web service client (scala+java+wsdl2java)

Viewed 1089

These other questions hint at a solution but I haven't been able to get this to work:
Could not resolve a binding for http://schemas.xmlsoap.org/wsdl/soap/
ServiceConstructionException when creating a CXF web service client
How to package an Apache CXF application into a monolithic JAR with the Maven "shade" plugin

When I start my application by doing java -Xdebug -jar myapp.jar I'm getting a ServiceConstructionException: Could not resolve a binding for null when the app makes a SOAP call. The app and the SOAP call works just fine when I start the application in IntelliJ. Here is a minimal example reproducing the error: https://github.com/stianlagstad/mainclass-and-jxf-problems-demo

Steps to reproduce:
- gradle clean build && java -Xdebug -jar build/libs/mainclass-and-jxf-problems-demo.jar
- Go to http://localhost:4242/endpoint/ and see the error

Can anyone help me figure out which changes I have to do to make the SOAP call work?

Edit to provide more information:

If I edit build.gradle to not exclude META-INF (i.e. having configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } instead of configurations.compile.collect { it.isDirectory() ? it : zipTree(it).matching{exclude{it.path.contains('META-INF')}} }) I get this error instead: Error: Could not find or load main class com.shadowjarcxfproblem.JettyLauncher (when starting the app as a jar). Starting the app in IntelliJ still works however, and the SOAP call works then as well.

The stacktrace for the cxf error:

org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve a binding for null
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:352)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:259)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:144)
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
    at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:157)
    at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
    at com.shadowjarcxfproblem.SoapServiceFactory.create(SoapServiceFactory.java:36)
    at com.shadowjarcxfproblem.service.CalculatorServiceComponent$CalculatorServiceImpl.<init>(CalculatorService.scala:17)
...
Caused by: org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered.
    at org.apache.cxf.bus.managers.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:93)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:339)
    ... 75 more
1 Answers
Related