最近我必须升级CXF 2.7 to CXF 3.1.2
。我们使用的spring版本是Spring 4.1.8
。
尝试在以下行中创建EndPointImpl对象时发生错误:
EndpointImpl myWSImpl = (EndpointImpl)Boot.getAppContext().getBean("myWebService");
请注意,我无法升级到Spring 4.2
,因此我必须在context.file
中注释掉这些行,以便cxf 3.1
使用Spring 4.1
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
我尝试过以下操作:
Bus bus = (Bus) Boot.getAppContext().getBean(Bus.DEFAULT_BUS_ID);
Object implementor = Boot.getAppContext().getBean("myWebService");
EndpointImpl myWSImpl = new EndpointImpl(bus, implementor);
但我仍然遇到同样的错误,我在日志中发现了以下错误:
04-Apr-2018 15:18:37.255 SEVERE [localhost-startStop-1]
org.apache.catalina.core.StandardContext.listenerStart Exception
sending context initialized event to listener instance of class
[org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'myWebService': Instantiation of bean failed;
nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.apache.cxf.jaxws.spring.EndpointDefinitionParser$SpringEndpointImpl]:
No default constructor found; nested exception is
java.lang.NoSuchMethodException:
org.apache.cxf.jaxws.spring.EndpointDefinitionParser$SpringEndpointImpl.<init>()
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1099)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1044)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
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:759)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
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:4745)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
at
org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1842)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source) at java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at
java.lang.Thread.run(Unknown Source) Caused by:
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.apache.cxf.jaxws.spring.EndpointDefinitionParser$SpringEndpointImpl]:
No default constructor found; nested exception is
java.lang.NoSuchMethodException:
org.apache.cxf.jaxws.spring.EndpointDefinitionParser$SpringEndpointImpl.<init>()
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1092)
... 26 more Caused by: java.lang.NoSuchMethodException:
org.apache.cxf.jaxws.spring.EndpointDefinitionParser$SpringEndpointImpl.<init>()
at java.lang.Class.getConstructor0(Unknown Source) at
java.lang.Class.getDeclaredConstructor(Unknown Source) at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80)
... 27 more
我还可以做些什么来消除此错误。
感谢。