Announcement Announcement Module
Collapse
No announcement yet.
DwrController problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DwrController problem

    I am trying to use DWR with Spring 2.5.6, and I cannot get DWR to vend /dwr/engine.js and its related JavaScript files. In fact, I ended up putting a breakpoint in DispatchServlet, and the attempt to get /dwr/engine.js raised an exception with message:

    No adapter for handler [org.directwebremoting.spring.DwrController@13777b3]: Does your handler implement a supported interface like Controller?
    DwrController extends Spring's AbstractController, which implements Controller, and so I am badly confused.

  • #2
    Missing Handler

    Hi,

    you have to add a DefaultHandler like:
    Code:
    <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    Here's a sample context:
    Code:
    <!-- DefaultHandlerAdapter   -->
        <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
        
        <!-- Url-Mapping for DWR.  -->
        <!-- wep_appname/contexRoot/engine.js  -->
        <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	 
    	  <property name="mappings">
    	  <props>
    	    <prop key="/engine.js">dwrController</prop>
    	    <prop key="/util.js">dwrController</prop>
    	    <prop key="/call/**">dwrController</prop>
    	    <prop key="/interface/**">dwrController</prop>
    	  </props>
    	  </property>
        </bean>
    
        <!-- mandatory  -->
        <dwr:controller id="dwrController" debug="true" />
    
        <!-- mandatory too, can be empty -->
        <!-- dem Spring-Context stehen. -->        
        <dwr:configuration/>
    
        <!-- Sample-DWR-Remote -->
    	<bean id="dwrService" class="net.yourPackage.YourRemoteClass">
    	   <dwr:remote javascript="YourDWRServiceName">
    	       <dwr:include method="exposedMethod" />
               <dwr:convert type="bean" class="net.yourpage.AnotherTypeReturnedByYourService" />
               <dwr:convert type="exception" class="java.lang.Exception"/>
               <dwr:convert type="bean" class="java.lang.StackTraceElement"/>
    	   </dwr:remote>
    	</bean>
    Annotation:
    • dwr:configuration:
      You can use this bean for dws:remote-entries. But then you have no spring-di in your remoteController.
    • urlMapping:
      Internally the DwrController looks for path (without context-path) beginning with /engine.js, /call/... So, if you have a path something like /dwr/engine.js (or webapp_name/aContextPath/dwr/engine.js) the DwrController cant find this in his own map.
    • Use exception-handling carefully (for security reasons)
    Another, and better solution, can be found here

    Best Regard
    michael
    Last edited by banzai1972; Sep 15th, 2010, 08:10 AM. Reason: wrong url

    Comment

    Working...
    X