的pom.xml
<cxf.core>3.1.8</cxf.core>
<cxf.version>3.1.8</cxf.version>
<jsr311.api.version>1.1.1</jsr311.api.version> <javax.ws.rs.api.version>2.0.1</javax.ws.rs.api.version>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs.api.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>${jsr311.api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>${cxf.core}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
<exclusions>
<exclusion>
<artifactId>cxf-common-utilities</artifactId>
<groupId>org.apache.cxf</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
<exclusions>
<exclusion>
<artifactId>cxf-common-utilities</artifactId>
<groupId>org.apache.cxf</groupId>
</exclusion>
</exclusions>
</dependency>
例外是:
WARN:2017-07-27 17:19:37.903:localhost-startStop-1:"Exception encountered during context initialization - cancelling refresh attempt":org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'caServiceClient' defined in URL [jar:file:/Users/vn0kt7d/Documents/workspace-checkout1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/checkoutservice/WEB-INF/lib/checkout-adapter-1.0.0.75-SNAPSHOT.jar!/environmentConfig/default/customer-account-client.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'caServiceClient' defined in URL [jar:file:/Users/vn0kt7d/Documents/workspace-checkout1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/checkoutservice/WEB-INF/lib/checkout-adapter-1.0.0.75-SNAPSHOT.jar!/environmentConfig/default/customer-account-client.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at com.walmart.platform.scm.client.execution.ScmServletContextListener.configureAndRefreshWebApplicationContext(ScmServletContextListener.java:87)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
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:748)
Caused by java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean
at com.walmart.platform.soa.client.AbstractJAXRSClient.getJAXRSBean(AbstractJAXRSClient.java:360)
at com.walmart.platform.soa.client.AbstractJAXRSClient.getProxy(AbstractJAXRSClient.java:275)
at com.walmart.platform.soa.client.annotation.SOAClientAnnotationProcessor.wireJAXRSClient(SOAClientAnnotationProcessor.java:464)
at com.walmart.platform.soa.client.annotation.SOAClientAnnotationProcessor.wireSOAClient(SOAClientAnnotationProcessor.java:89)
at com.walmart.platform.soa.client.annotation.SOAClientAnnotationProcessor.access$000(SOAClientAnnotationProcessor.java:42)
at com.walmart.platform.soa.client.annotation.SOAClientAnnotationProcessor$1.doWith(SOAClientAnnotationProcessor.java:65)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:605)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:585)
at com.walmart.platform.soa.client.annotation.SOAClientAnnotationProcessor.postProcessAfterInstantiation(SOAClientAnnotationProcessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1172)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 20 more
Caused by java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
... 31 more
仅供参考,我已明确添加了JaxB-Impl依赖项,因为:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'example': Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: REFLECTION
此问题的根本原因是什么?
答案 0 :(得分:0)
您应该将cxf-rt-rs-client
添加为依赖项。
此外,我会删除jsr311 api并使用2.0版本。