I’m using DWR version 3.0.3-dev-665 with the AMD loader. I have multiple web components that each use DWR. The first component has no issues with DWR method calls. The second component always fails. DWR config for the second component is:
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>scriptCompressed</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>amdDwrBaseModulePath</param-name>
<param-value>mydwr</param-value>
</init-param>
<init-param>
<param-name>amdInterfaceBaseModulePath</param-name>
<param-value>myapp</param-value>
</init-param>
<init-param>
<param-name>amdDtoBaseModulePath</param-name>
<param-value>mydata</param-value>
</init-param>
<init-param>
<param-name>generateDtoClasses</param-name>
<param-value>dto</param-value>
</init-param>
<init-param>
<param-name>activeReverseAjaxEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.directwebremoting.extend.ServerLoadMonitor</param-name>
<param-value>org.directwebremoting.impl.PollingServerLoadMonitor</param-value>
</init-param>
<init-param>
<param-name>overridePath</param-name>
<param-value>myOverriddenPath</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>`
In my JSP, I include my required modules like so:
require(djConfig,
[ "dojo/parser",
"dojo/ready",
"mydwr/engine",
"myapp/Class1",
"myapp/Class2",
"mydata/Bean1",
"mydata/Bean2"
],
function(parser, ready, terminaldwr, MyClass1, MyClass2){
ready(function() {
mydwr.setAsync(true);
SomeGlobalClassName = MyClass1;
SomeOtherGlobalClassName = MyClass2;
...
});
});
When SomeGlobalClassName calls one of its remote methods, the call fails and the server replies with either a session timeout error or a TextHTML error. However, if I debug and break inside the DWR-generated JS file (/myOverriddenPath/dwr/amd/interface/MyClass1.js), I see this:
define(["mydwr/engine"], function(dwr) {
var p;
p = {};
/**
* @param {class java.lang.String} p0 a param
* @param {class java.lang.String} p1 a param
* @param {boolean} p2 a param
* @param {function|Object} callback callback function or options object
*/
p.myMethod = function(p0, p1, p2, callback) {
return dwr.engine._execute(p._path, 'Class1', 'myMethod', arguments);
};
return p;
});
As we can see, the _path property of p is never set. If I break before the execution of this function and use the console to set p._path = dwr._pathToDwrServlet, then the remote call succeeds.
My question is why is this _path property not being set when the JS is generated, or is there something else I need to do in the configuration to make this work?