Search code examples
spring-wsspring-4

Is spring-ws-2.2.0 compatible with spring 4?


I am trying to upgrade from Spring 3 to 4 and I stumbled upon an issue. We use spring-ws and I have updated to the latest release (2.2.0). I am getting a java.lang.NoSuchMethodError exception

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 has this:

<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"/>

It appears that a spring-ws class is trying to call a method in spring-core-4 that no longer exists. I was under the impression that spring-ws 2.2.0 was compatible with spring 4.

To be precise I have Spring 4.0.6. for spring-ws I am using spring-ws-core-2.2.0.RELEASE.jar

Any insight would be appreciated


Solution

  • Yes, it is compatible.

    From other side Spring Integration uses Spring WS 2.2 as well and already without any issue during upgrade roadmap up to Spring Framework 4.2.

    Please, be sure that you really don't have old versions of those frameworks in the classpath.