我正在尝试从Spring 3升级到4,我偶然发现了一个问题。我们使用spring-ws,我已经更新到最新版本(2.2.0)。我收到了java.lang.NoSuchMethodError异常
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportWebServiceTemplate' defined in class path resource [config/report_ws_context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.ws.client.core.WebServiceTemplate]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org/springframework/util/ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
... 40 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.ws.client.core.WebServiceTemplate]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org/springframework/util/ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:125)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:270)
... 49 more
Caused by: java.lang.NoSuchMethodError: org/springframework/util/ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;
at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategies(DefaultStrategiesHelper.java:114)
at org.springframework.ws.support.DefaultStrategiesHelper.getDefaultStrategies(DefaultStrategiesHelper.java:90)
at org.springframework.ws.client.core.WebServiceTemplate.initMessageSenders(WebServiceTemplate.java:321)
at org.springframework.ws.client.core.WebServiceTemplate.initDefaultStrategies(WebServiceTemplate.java:307)
at org.springframework.ws.client.core.WebServiceTemplate.<init>(WebServiceTemplate.java:143)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
report_ws_context.xml包含:
<bean id="reportWebServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory" />
<property name="messageSender" ref="messageSender" />
<property name="marshaller" ref="getReportInfoMarshaller" />
<property name="unmarshaller" ref="getReportInfoUnmarshaller" />
<property name="defaultUri" ref="reportingServiceUri" />
<property name="interceptors" ref="securityInterceptor"/>
看起来spring-ws类试图在spring-core-4中调用一个不再存在的方法。我认为spring-ws 2.2.0与spring 4兼容。
确切地说,我有Spring 4.0.6。 对于spring-ws我使用spring-ws-core-2.2.0.RELEASE.jar
任何见解都将受到赞赏
答案 0 :(得分:2)
是的,它是compatible。
另一方面,Spring Integration也使用Spring WS 2.2,在升级路线图到Spring Framework 4.2之前已经没有任何问题。
请确保您在类路径中确实没有这些框架的旧版本。