Question

I introduce DWR into my project these days. My project is using Spring 4, I was trying to integrate DWR with Spring by using annotation approch. Below are my code for integration work. An error shown as below occured when I stratup my project on the Tomcat server.

the error:

java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;
at org.directwebremoting.spring.DwrAnnotationPostProcessor.getBeanDefinitionClass(DwrAnnotationPostProcessor.java:96)
at org.directwebremoting.spring.DwrAnnotationPostProcessor.postProcessBeanFactory(DwrAnnotationPostProcessor.java:52)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPos
Processors(PostProcessorRegistrationDelegate.java:265)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:177)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)

web.xml

<servlet>
  <servlet-name>dwr-dispatcher</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>2</load-on-startup>
</servlet>

dwr-dispatcher-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">

<context:annotation-config />
<context:component-scan base-package="com.xdfaint.webapp.apps.*.action" />
<dwr:configuration />
<dwr:annotation-config id="dwrAnnotationConfig" />
<dwr:url-mapping />
<dwr:controller id="dwrController" debug="true" />


<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
  <property name="order" value="1" />
</bean>

<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
  <property name="order" value="2" />
</bean>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="prefix">
    <value>/core/jsp/</value>
  </property>
  <property name="suffix">
    <value>.jsp</value>
  </property>
</bean>

</beans>

I haven't found any solution yet. Then I try to use Spring 3.2 instead, the startup successed with no error any more. I am not sure if there are problems when Spring 4 meets DWR3. Can any body help? Thx~


DWR haven't updated for a long time, and I am not using it anymore. But it is still great helpful that worth to read source codes for studying, like concept of how rest api binding, object operating. About object operating, I found some useful functions like setObject(), was using massively when I did a frontend components encapsulation work. Both setObject function codes and using demo list below, with it I can init a filed in a any nested level of the object, even if there are number of parents object of that new field hasn't been declared yet.

enter image description here

Was it helpful?

Solution

In Spring 4 there is no method forName in ClassUtils that only accepts String as an argument. As you can see from the JavaDoc here that method was already deprecated in Spring 3

It seems that DWR has not yet upgraded their code base to support Spring 4. Seems like you'll have to wait for that to happen (although the project seems to be non-active so I wouldn't count on that happening any time soon).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top