Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on using camel cxf "No binding factory... http://schemas.xmlsoap.org/soap/ registered" (but works in eclipse)

In my camel app i am creating cxf endpoints in java dsl:

CxfEndpoint cxf = new CxfEndpoint(rtdmUrl, new CxfComponent(this.getContext()));
cxf.setServiceClass(EventPortType.class);
process.process(rtdmSetNameFactory.get(eventName)).to(cxf).process(handleRtdmAnswer);

If try to run this route i get:

Exception in thread "main" org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: End
point[http://localhost:8088/mockEventSoapBinding]. Reason: org.apache.cxf.service.factory.ServiceConstructionException:
Could not resolve a binding for null
...
Caused by: org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered.

But if i run main[] from within eclipse (called in a @Test with same configuration) it is working fine!?

My jar is built with maven-assembly-plugin (executable jar with all dependencies) I hope/think this is only a configuration problem or is related to how i set up the cxf endpoint.

Additional info for bounty hunters I created a minimal example that reproduces the error: https://bitbucket.org/moritz_loeser/cxftests/src

It contains a test that calls main() this test is working if you change the path in the route (it creates a exchange per file, but file content is ignored). I used soapUi (project file within above repository) to mock the web service. On my machine the test works fine but running mvn package and then java -jar cxfTests-1.0-SNAPSHOT-jar-with-dependencies.jar from target folder fails. i just tried: mvn test is also working

this is the dependency tree:

[INFO] com.sas:cep-adapter-java:jar:1.0-SNAPSHOT 
[INFO] +- com.sas:dfESP-component:jar:1.0-SNAPSHOT:compile 
[INFO] |  \- dfx-esp-api:api:jar:2.2-post:compile 
[INFO] +- com.sas.o2:RTDM_general_client:jar:0.0.1-SNAPSHOT:compile 
[INFO] +- com.google.inject:guice:jar:3.0:compile 
[INFO] |  +- javax.inject:javax.inject:jar:1:compile 
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile 
[INFO] +- com.google.inject.extensions:guice-multibindings:jar:3.0:compile 
[INFO] +- com.google.guava:guava:jar:16.0.1:compile 
[INFO] +- joda-time:joda-time:jar:2.3:compile 
[INFO] +- org.apache.camel:camel-core:jar:2.13.1:compile 
[INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.6:compile 
[INFO] +- org.apache.camel:camel-ftp:jar:2.13.1:compile 
[INFO] |  +- com.jcraft:jsch:jar:0.1.50:compile 
[INFO] |  \- commons-net:commons-net:jar:3.3:compile 
[INFO] +- org.apache.camel:camel-cxf:jar:2.13.1:compile 
[INFO] |  +- org.apache.camel:camel-spring:jar:2.13.1:compile 
[INFO] |  |  +- org.springframework:spring-aop:jar:3.2.8.RELEASE:compile 
[INFO] |  |  \- org.springframework:spring-tx:jar:3.2.8.RELEASE:compile 
[INFO] |  +- org.apache.camel:camel-cxf-transport:jar:2.13.1:compile 
[INFO] |  +- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:2.7.11:compile 
[INFO] |  |  +- org.apache.cxf:cxf-api:jar:2.7.11:compile 
[INFO] |  |  |  +- org.codehaus.woodstox:woodstox-core-asl:jar:4.2.1:compile 
[INFO] |  |  |  |  \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile 
[INFO] |  |  |  +- org.apache.ws.xmlschema:xmlschema-core:jar:2.1.0:compile 
[INFO] |  |  |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile 
[INFO] |  |  |  \- wsdl4j:wsdl4j:jar:1.6.3:compile 
[INFO] |  |  +- org.apache.cxf:cxf-rt-core:jar:2.7.11:compile 
[INFO] |  |  +- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10:compile 
[INFO] |  |  +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.7.11:compile 
[INFO] |  |  \- org.apache.cxf:cxf-rt-transports-http:jar:2.7.11:compile 
[INFO] |  +- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.7.11:compile 
[INFO] |  |  +- xml-resolver:xml-resolver:jar:1.2:compile 
[INFO] |  |  +- asm:asm:jar:3.3.1:compile 
[INFO] |  |  +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.7.11:compile 
[INFO] |  |  \- org.apache.cxf:cxf-rt-ws-addr:jar:2.7.11:compile 
[INFO] |  |     \- org.apache.cxf:cxf-rt-ws-policy:jar:2.7.11:compile 
[INFO] |  |        \- org.apache.neethi:neethi:jar:3.0.3:compile 
[INFO] |  +- org.apache.cxf:cxf-rt-rs-security-oauth:jar:2.7.11:compile 
[INFO] |  |  \- net.oauth.core:oauth-provider:jar:20100527:compile 
[INFO] |  |     \- net.oauth.core:oauth:jar:20100527:compile 
[INFO] |  +- org.springframework:spring-core:jar:3.2.8.RELEASE:compile 
[INFO] |  |  \- commons-logging:commons-logging:jar:1.1.3:compile 
[INFO] |  +- org.springframework:spring-beans:jar:3.2.8.RELEASE:compile 
[INFO] |  +- org.springframework:spring-context:jar:3.2.8.RELEASE:compile 
[INFO] |  |  \- org.springframework:spring-expression:jar:3.2.8.RELEASE:compile 
[INFO] |  +- org.apache.cxf:cxf-rt-features-clustering:jar:2.7.11:compile 
[INFO] |  \- org.apache.cxf:cxf-rt-bindings-soap:jar:2.7.11:compile
[INFO] |     \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.7.11:compile 
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile 
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.7:compile 
[INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.7:compile 
[INFO] +- log4j:log4j:jar:1.2.17:compile 
[INFO] +- org.apache.camel:camel-test:jar:2.13.0:test 
[INFO] +- junit:junit:jar:4.11:test 
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:compile 
[INFO] +- org.mockftpserver:MockFtpServer:jar:2.4:compile 
[INFO] +- org.jukito:jukito:jar:1.4:compile 
[INFO] |  +- org.mockito:mockito-core:jar:1.9.5:compile 
[INFO] |  |  \- org.objenesis:objenesis:jar:1.0:compile 
[INFO] |  \- com.google.inject.extensions:guice-assistedinject:jar:3.0:compile 
[INFO] \- org.hamcrest:hamcrest-all:jar:1.3:compile 

My main method look like this:

public static void main(final String... args) throws Exception { 
    Injector i; 
    if (args.length < 1 || Strings.isNullOrEmpty(args[0])) { 
        i = Guice.createInjector(new CepModule()); 
    } else { 
        i = Guice.createInjector(new CepModule(args[0])); 
    } 
    OurMain main = i.getInstance(OurMain.class); 
    // eliminates logging to java.util.logger 
    SLF4JBridgeHandler.removeHandlersForRootLogger(); 
    // redirects all java.util.logger stuff to slf4j 
    SLF4JBridgeHandler.install(); 
    //i.getInstance(RouteControl.class).startAll(); 
    main.enableHangupSupport(); 
    main.run(); 
} 

As stated before the test that works in eclipse just runs this method with same configuration file as the test that throws this error (run from console java -jar thejat.jar).

like image 508
dermoritz Avatar asked Jun 26 '14 12:06

dermoritz


2 Answers

I had similar error while migrating cxf from 2.3.1 to 2.6.6. In my case like in post before:

It seems that assembly-plugin messes up configuration files (overriding in not specific order). So the solution is don't use it! But use shade plugin like here: How to package an Apache CXF application into a monolithic JAR with the Maven "shade" plugin

but I should tried add only :

<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/cxf/bus-extensions.txt</resource> </transformer>

(answer in that post too), not all transformenrs, and I don't need buildtools

like image 157
paka Avatar answered Sep 19 '22 08:09

paka


i found an answer on a not so clean path but the final hint came from here: http://cxf.547215.n5.nabble.com/Error-on-using-camel-cxf-quot-No-binding-factory-http-schemas-xmlsoap-org-soap-registered-but-works--td5745738.html

It seems that assembly-plugin messes up configuration files (overriding in not specific order). So the solution is don't use it! But use shade plugin like here: How to package an Apache CXF application into a monolithic JAR with the Maven "shade" plugin

(Answer by corneil)

The only problem i have with it: i don't understand how to properly choose files and transformers. Do i need all of them? Which file is producing my specific error?

like image 36
dermoritz Avatar answered Sep 18 '22 08:09

dermoritz