Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

dwr & SpringMVC

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

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 :

<display-name>DWR Servlet</display-name>




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

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

<bean id="dwrController" class="org.springframework.web.servlet.mvc.ServletWrappingController">
<property name="servletClass">
<property name="initParameters">
<prop key="debug">true</prop>

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

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

<?xml version="1.0" encoding="UTF-8"?>


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



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.



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

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.