java - 如何将CXF从 2.7迁移到 3.0?

  显示原文与译文双语对照的内容
0 0

我在版本 2.7.11中使用了 CXF 。 我修改了版本 3.0.4的版本。 CXF集成到 Spring Framework 应用程序中。

我只能在拦截器类中修复一个编译错误。

Conduit conduit = exchange.getDestination().getBackChannel(inMessage, null, target); 已经更改 Conduit conduit = exchange.getDestination().getBackChannel(inMessage);

我将它部署在Tomcat上,但在这里错误上失败:


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activity': Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: REFLECTION
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
 at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:479)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
 at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1763)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:622)
 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:856)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:805)
 at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
 at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:622)
 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:856)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:805)
 at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1476)
 at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:98)
 at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1317)
 at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1409)
 at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:839)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:622)
 at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
 at sun.rmi.transport.Transport$2.run(Transport.java:202)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.Transport.serviceCall(Transport.java:198)
 at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:564)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:825)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.access$400(TCPTransport.java:616)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(TCPTransport.java:681)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(TCPTransport.java:678)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:678)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:701)
Caused by: java.lang.NoSuchFieldError: REFLECTION
 at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:93)
 at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:464)
 at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:310)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:534)
 at org.zeroturnaround.jrebel.jaxb.proxy.JaxbContextFactory.buildContext(JaxbContextFactory.java:31)
 at org.zeroturnaround.jrebel.jaxb.proxy.JaxbContextProxyHandler.buildContext(JaxbContextProxyHandler.java:133)
 at org.zeroturnaround.jrebel.jaxb.proxy.JaxbContextProxyHandler.<init>(JaxbContextProxyHandler.java:103)
 at org.zeroturnaround.jrebel.jaxb.proxy.JaxbContextProxy.createProxy(JaxbContextProxy.java:68)
 at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1169)
 at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:622)
 at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222)
 at javax.xml.bind.ContextFinder.find(ContextFinder.java:383)
 at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:594)
 at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:347)
 at org.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345)
 at java.security.AccessController.doPrivileged(Native Method)
 at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:345)
 at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)
 at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:479)
 at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:334)
 at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
 at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:467)
 at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:712)
 at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:527)
 at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261)
 at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
 at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
 at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
 at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
 at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
 at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)
 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:539)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:622)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1612)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1553)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
. . . 59 more

下面是我的CXF上下文文件,它被导入 spring 上下文文件。


<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:jaxws="http://cxf.apache.org/jaxws"
 xmlns:cxf="http://cxf.apache.org/core"
 xmlns="http://www.springframework.org/schema/beans"
 xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

 <import resource="classpath:META-INF/cxf/cxf.xml"/>
 <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

 <bean id="ActivityWebService" class="com.example.activity.ActivityWebService"/>
 <jaxws:endpoint id="activity" implementor="#ActivityWebService" address="/Activity"/>

 <cxf:bus>
 <cxf:inInterceptors>
 <ref bean="basicAuthAuthorizationInterceptor"/>
 </cxf:inInterceptors>
 </cxf:bus>

 <bean id="basicAuthAuthorizationInterceptor" class="com.example.api.BasicAuthAuthorizationInterceptor"/>

</beans>

时间: 原作者:

0 0

这似乎是 https://issues.apache.org/jira/browse/CXF-5894的"重复": 请检查你的类路径是否有冲突的jaxb- 库 !

...