Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

dwr & SpringMVC

  Asked By: Thelma    Date: Mar 19    Category: Java    Views: 1321
  

I'm using spring MVC (spring version 1.2.1) , i want to use dwr(1.4.1) in my application. I've just configured my application as :


web.xml
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>

<servlet>
<servlet-name>mainServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
<servlet-name>mainServlet</servlet-name>
<url-pattern>dwr/*</url-pattern>
</servlet-mapping>



------------------------------------------------------------------------------------------
applicationContext.xml

<bean id="stateDAO" class="com.realdevelopment.videonary.dao.specific.StateDAO">
<property name="sessionFactory">
<ref bean="TECSSessionFactory"/>
</property>
</bean>



<bean id="ajaxUtils" class="com.realdevelopment.videonary.web.utils.AjaxUtils">
<property name="stateDAO">
<ref bean="stateDAO"/>
</property>
</bean>
------------------------------------------------------------------------------------------
application_servlet.xml

<bean id="dwrController" class="org.springframework.web.servlet.mvc.ServletWrappingController">
<property name="servletClass">
<value>uk.ltd.getahead.dwr.DWRServlet</value>
<!--<value>org.directwebremoting.servlet.DwrServlet</value>-->
</property>
<property name="initParameters">
<props>
<prop key="debug">true</prop>
</props>
</property>
</bean>

<bean id="mainUrlHandler" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
..............
..............
..............
<prop key="dwr/**/*">dwrController</prop>
<prop key="dwr/**/*">dwrController</prop>
<prop key="**/*.js">dwrController</prop>
<prop key="exec/*">dwrController</prop>

</props>
</property>
<property name="interceptors">
<list>
<ref bean="clickStreamInterceptor"/>
<ref bean="openSessionInViewInterceptor"/>
<ref bean="mainMenuHighlighterInterceptor"/>
<ref bean="userMenuHighlighterInterceptor"/>
<ref bean="adminMenuHighlighterInterceptor"/>
</list>
</property>
</bean>


------------------------------------------------------------------------------------------
dwr.xml
<?xml version="1.0" encoding="UTF-8"?>
http://www.getahead.ltd.uk/dwr/dwr10.dtd">

<dwr>
<allow>
<convert
converter="bean"
match="com.realdevelopment.videonary.web.utils.AjaxUtils"/>

<create
creator="spring"
javascript="ajaxUtils" class = "uk.ltd.getahead.dwr.create.SpringCreator" >
<include method="getStateList"/>
<param name="beanName" value="ajaxUtils"/>
<!-- nothing's going to change if i comment this line-->
<param name="location" value="/WEB-INF/applicationContext.xml"/>

</create>
</allow>

</dwr>

But when i tun it i get an error like this
missing spring creator while creating ajaxUtils.js

When I debug dwr source it encounter this error
org/springframework/beans/factory/BeanFactory does not exist.

I would appreciate if someone could help me and tell me how can fix this problem.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Este Ferrrari     Answered On: Mar 19

As far as I remember dwr  2 uses spring  namespaces which is a Spring 2 feature. So I suggest you to upgrade to Spring 2.0.x before you start. I believe that You will face no serious problem  in this upgrade.
----------------------------------------------------------------------------------
I had once configured  spring with DWR old version. As far as I remember you had two options to configure dwr:
1- defining the dwr servlet  in web.xml
2- defining the dwr servlet as a bean in spring context files.

I can see that you have configured both. I guess this is wrong. Check this out.
Take away that servlet "dwr-invoker" from the web.xml but don't touch the main servlet. It is configured correctly.
And in the simpleUrlHandlerMapping bean, take away all of those


<prop key="dwrSomething">dwrController</prop>
and replace them with the red line in the end of the props like this:
<property name="mappings">
<properties>
<prop key="/first.htm">firstController</prop>
<prop key="/last.htm">lastController</prop>
<!-- This mapping is required for DWR / Spring configuration -->
<!-- NOTE: This mapping should always be the last line cause it handles
all the calls which are not catched by prev mappings -->
<prop key="/**/*">dwrController</prop>
</properties>
</property>

This was the trick that we used to use with dwr 1 to let spring map dwr from inside. If you have more problems, I suggest you to join the spring and dwr mailing list. This must have been a frequently asked question out there and you see lots of related questions and answers that might be useful as well.

 
Didn't find what you were looking for? Find more on dwr & SpringMVC Or get search suggestion and latest updates.




Tagged: