« Return to Thread: Spring 2.0.6 + DWR 2.0

Re: Spring 2.0.6 + DWR 2.0

by dio :: Rate this Message:

Reply to Author | View in Thread

You can use the following sample web.xml and spring-servlet.xml. It is working fine

-- Deha Peker

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>
                        /WEB-INF/mrsi-db-context.xml, /WEB-INF/mrsi-dao-context.xml,
                        /WEB-INF/applicationContext.xml, /WEB-INF/spring-servlet.xml
                </param-value>
        </context-param>
        <filter>
        <filter-name>requestContextFilter</filter-name>
        <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>requestContextFilter</filter-name>
        <url-pattern>/dwr/*</url-pattern>
    </filter-mapping>
        <listener>
                <listener-class>.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
                <servlet-name>spring</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>spring</servlet-name>
                <url-pattern>*.do</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
                <servlet-name>spring</servlet-name>
                <url-pattern>/dwr/*</url-pattern>
        </servlet-mapping>
</web-app>

... And spring-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
      http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
<bean id="dwrHandlerMappings"
        ="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                <property name="order" value="1" />
                <property name="alwaysUseFullPath" value="true"></property>
                <property name="mappings">
                        <props>
                                <prop key="/dwr/**/*">dwrController</prop>
                                <prop key="/dwr/*">dwrController</prop>
                        </props>
                </property>
        </bean>
        <dwr:controller id="dwrController" debug="true">
                <dwr:config-param name="activeReverseAjaxEnabled" value="true" />
        </dwr:controller>
        <dwr:configuration>
                <dwr:create type="new" javascript="JsDate" type="java.util.Date"/>
                <dwr:convert type="bean" class="domain.exposures.ExposuresId">
                        <dwr:include method="cob" />
                        <dwr:include method="bus" />
                </dwr:convert>
        </dwr:configuration>
        <bean id="scenAJAXController" class="web.controller.ScenAJAXController" scope="session">
                <property name="scenService"><ref bean="siScenService" /></property>
                <dwr:remote javascript="JsScenAJAXController">
                        <dwr:include method="methodFoo" />
                        <dwr:include method="methodBoo" />
                </dwr:remote>
        </bean>
</beans>

Jagan Bala wrote:
Hello All,

Iam trying to integrate DWR with my spring application. Iam using spring version 2.0.6 and DWR version 2.0. I have made all the configurations and when i request a url like http://localhost:7001/<<myWebApp??/dwr/ i get an error listed below
 org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '
__dwrConfiguration' is defined

Any help on how to resolve this issue would be highly appreciated. I have listed my configurations below and please let me know if i need to do more.

Thanks
Jagan

-- Configurations --

1. web.xml
  <servlet>
        <servlet-name>dwr</servlet-name>
        <servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>
  <servlet-mapping>
        <servlet-name>dwr</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

2. Myspringapp-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"

xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">

    <!--Dwr settings -->    
   
        <bean id="dwrUrlMapping" 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>
                    </props>
            </property>
       
        </bean>

    <!-- DWR Controller -->
    <dwr:controller id="dwrController" debug="false" />  

 <dwr:configuration>


    <dwr:convert type="bean" class="org.springframework.validation.ObjectError" />
    <dwr:convert type="bean" class=" org.springframework.validation.BindException">
        <dwr:include method="allErrors" />
    </dwr:convert>

    <!-- Dwr converts -->
   <dwr:convert type="bean" class="com.example.objects.*"/>

    </dwr:configuration>

 « Return to Thread: Spring 2.0.6 + DWR 2.0

LightInTheBox - Buy quality products at wholesale price