javaspringdwr

DWR 3 and Spring 4


I have a problem with DWR 3 and Spring 4 which drives me crazy.

There is a class that has 2 methods:

package xxx.dwr.services;

@RemoteProxy
public class UnitsService extends DwrSupport {
    @RemoteMethod
    public List<UnitTreeNode> searchTreeNodes(UnitTreeSearchQuery query) {
        ...
    }
    @RemoteMethod
    public List<UnitTreeNode> getTreeNodes(String parentNodeId, String clientIdString,boolean searchInHistory) {
        ...
    }
}

When I click on the menu to open the unit tree page the getTreeNodes is called and it works fine, I can see the tree. The tree can be filtered and in this case the searchTreeNodes method should be called but all I can see in the browser is a javascript alert dialog saying 'Error'.

In the browser's console I can see the following:

dwr.engine._debug @ engine.js:984
dwr.engine.defaultErrorHandler @ engine.js:215
(anonymous) @ engine.js:1121
logHandlerEx @ engine.js:2553
handleException @ engine.js:1107
(anonymous) @ VM1365:9
(anonymous) @ VM1365:10
dwr.engine._executeScript @ engine.js:720
stateChange @ engine.js:1791
batch.req.onreadystatechange @ engine.js:1664
Error: undefined, Error

Which is not a lot of information...

So I can call one method but not the other one in the same class!

The data transfer objects are as follows (normal beans with getters and setters):

package xxx.dwr.services.dto;
@DataTransferObject
public class UnitTreeNode {
    ....
}

package xxx.dwr.services.dto;
@DataTransferObject
public class UnitTreeSearchQuery {
    private UnitTreeSearchQueryField field;
    private String input;
    private String clientId;
    private boolean searchInHistory;
    ...
}

package xxx.dwr.services.dto;
@DataTransferObject(converter = EnumConverter.class)
public enum UnitTreeSearchQueryField {
    EXTID,
    DISPLAYNAME,
    ABBRNAME,
    NAME,
    REMARKS,
    LOCATION,
    STATE
}

The relating servlet configuration:

<servlet>
    <servlet-name>DwrServlet</servlet-nam1e>
    <servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>
    <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>allowScriptTagRemoting</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <!-- disabled due to reverse proxy setup -->
        <param-name>crossDomainSessionSecurity</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <!-- suppress the about DWR url -->
        <param-name>url:/about</param-name>
        <param-value>null</param-value>
    </init-param>
</servlet>

And from the context.xml

<dwr:configuration/>
<dwr:annotation-scan base-package="xxx.dwr.services" scanDataTransferObject="true" scanRemoteProxy="true" />

So I am at a complete loss what can go wrong. The Spring config should be fine as I can call one of the method from the web app.

Could you please help me?

Thanks,
V.


Solution

  • Not sure why but I couldn't send the parameter as an object. Now I do the following (passing simple parameters):

    @RemoteMethod
    public List<UnitTreeNode> searchTreeNodes(String field, String input, String clientId, String searchInHistory) {
    

    and it works.