2017-03-20 61 views
0

我正在尝试将一些功能集成到我的软件中,该软件需要Apache CXF Bundle(2.7.18)对某些Web服务进行SOAP调用。与Spring Framework和Apache CXF依赖冲突 - '没有这样的方法'

我pom.xml文件看起来像:

<dependency> 
    <--This is the new dependency I am integrating into my software--> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-bundle</artifactId> 
    <version>2.7.18</version> 
</dependency> 

//other dependencies 

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-web</artifactId> 
    <version>4.3.3.RELEASE</version> 
</dependency> 

该项目建立精细与Maven,但是当我尝试加载.war文件到Wildfly,我收到下面的堆栈跟踪:

Context initialization failed: java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration.<init>(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V 
at org.springframework.context.expression.StandardBeanExpressionResolver.<init>(StandardBeanExpressionResolver.java:98) 
at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:557) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:455) 
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) 
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) 
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) 
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173) 
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:195) 
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100) 
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:745) 
at org.jboss.threads.JBossThread.run(JBossThread.java:320) 

2017-03-20 14:27:45,076 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 340) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./p6pmtjsonresponse: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./p6pmtjsonresponse: java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration.<init>(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V 
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
    at org.jboss.threads.JBossThread.run(JBossThread.java:320) 
Caused by: java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration.<init>(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V 
    at org.springframework.context.expression.StandardBeanExpressionResolver.<init>(StandardBeanExpressionResolver.java:98) 
    at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:557) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:455) 
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) 
    at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173) 
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:195) 
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100) 

任何想法可能会导致这种情况?我想知道是否应该排除一些传递性依赖或类似的东西?如果可能的话,我愿意使用CXF以外的其他框架。

我认为冲突是由于试图使用两个造成冲突的框架。

在此先感谢!

回答

1

我能够通过升级到CXF 3.1.10和Spring 4.3.3,然后用个人替换CXF-Bundle我需要的依赖关系如:

<dependency> 
    <groupId>org.apache.wss4j</groupId> 
    <artifactId>wss4j</artifactId> 
    <version>2.1.8</version> 
    <type>pom</type> 
</dependency> 

<dependency> 
    <groupId>org.apache.wss4j</groupId> 
    <artifactId>wss4j-ws-security-common</artifactId> 
    <version>2.1.8</version> 
</dependency> 
<dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-rt-frontend-jaxws</artifactId> 
    <version>3.1.10</version> 
</dependency> 
<dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-rt-transports-http</artifactId> 
    <version>3.1.10</version> 
</dependency> 
<!-- Jetty is needed if you're are not using the CXFServlet --> 
<dependency> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-rt-transports-http-jetty</artifactId> 
    <version>3.1.10</version> 
</dependency> 
1

spring-web依赖带来以下春瓶:

spring-aop-4.3.3.RELEASE.jar 
spring-beans-4.3.3.RELEASE.jar 
spring-context-4.3.3.RELEASE.jar 
spring-core-4.3.3.RELEASE.jar 
spring-expression-4.3.3.RELEASE.jar 
spring-web-4.3.3.RELEASE.jar 

添加cxf-bundle依赖会导致以下春瓶:

spring-aop-4.3.3.RELEASE.jar 
spring-asm-3.0.7.RELEASE.jar   ** 
spring-beans-4.3.3.RELEASE.jar 
spring-context-4.3.3.RELEASE.jar 
spring-core-4.3.3.RELEASE.jar 
spring-expression-3.0.7.RELEASE.jar ** Replaced 4.3.3 
spring-jms-3.0.7.RELEASE.jar   ** 
spring-tx-3.0.7.RELEASE.jar   ** 
spring-web-4.3.3.RELEASE.jar 

正如你所看到的,CXF使用Spring 3.0.7 ,而Spring 3.0与Spring 4.3不兼容。

你可以尝试显式地添加依赖来强制所有的Spring jar文件到4.3.3版本,但是我怀疑这会起作用。 Spring 3和Spring 4之间的内部更改过多。

+0

我会尝试手动添加依赖以及yaswanth所述的解决方案,并将更新此线程。感谢您的反馈。 – Bryce

0

与cxf 2.x.x相比,cxf 3.x.x有许多类名称和程序包名称更改。在我们的项目中,spring 4.1.6.RELEASE与cxf 2.7.x一起工作良好

+0

有趣。我会给4.1.6 RELEASE一个去并跟进。感谢您的反馈。 – Bryce