使用camel cxf时出错"没有绑定工厂... http://schemas.xmlsoap.org/soap/ registered"(但在eclipse中有效)

der*_*itz 5 cxf apache-camel

在我的骆驼应用程序中,我在java dsl中创建cxf端点:

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

如果尝试运行此路线我得到:

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.
Run Code Online (Sandbox Code Playgroud)

但是如果我在eclipse中运行main [](在具有相同配置的@Test中调用)它运行正常!?

我的jar是用maven-assembly-plugin构建的(带有所有依赖项的可执行jar)我希望/认为这只是一个配置问题或者与我如何设置cxf端点有关.

赏金猎人的其他信息 我创建了一个重现错误的最小例子:https: //bitbucket.org/moritz_loeser/cxftests/src

它包含一个调用main()的测试,如果您更改路径中的路径,则此测试正在运行(它会为每个文件创建一个交换,但会忽略文件内容).我使用soapUi(上面的存储库中的项目文件)来模拟Web服务.在我的机器上,测试工作正常但正在运行mvn package,然后java -jar cxfTests-1.0-SNAPSHOT-jar-with-dependencies.jar从目标文件夹失败. 我刚试过:mvn test也正常工作

这是依赖树:

[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 
Run Code Online (Sandbox Code Playgroud)

我的主要方法如下:

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(); 
} 
Run Code Online (Sandbox Code Playgroud)

如前所述,在eclipse中运行的测试只运行此方法,其配置文件与抛出此错误的测试相同(从控制台运行java -jar thejat.jar).

pak*_*aka 6

将cxf从2.3.1迁移到2.6.6时,我遇到了类似的错误.在我的情况下像之前的帖子:

似乎assembly-plugin会混淆配置文件(以非特定顺序覆盖).所以解决方案是不要使用它!但是使用像这里的shade插件:如何使用Maven"shade"插件将Apache CXF应用程序打包成单片JAR

但我应该尝试只添加:

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

(在那篇文章中也回答),不是所有的变换者,我也不需要构建工具


der*_*itz 3

我在一条不太干净的路径上找到了答案,但最终的提示来自这里: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

看来 assembly-plugin 弄乱了配置文件(以非特定顺序覆盖)。所以解决办法就是不要使用它!但是使用像这里这样的阴影插件: How to package an Apache CXF application into a monolithic JAR with the Maven "shade" plugin

(科尼尔回答)

我遇到的唯一问题是:我不明白如何正确选择文件和变压器。我需要全部吗?哪个文件产生了我的特定错误?