We have a web application that is using Spring framework 5.1.7.RELEASE, JDK 1.8 and DWR 3.0.2 deployed in WAS 8.5. We have a JSP web page; that displays some statistical information to its user; web page was working fine like in years and all of a sudden it started failing to load. When we debugged the issue; we narrow it down to dwr's ajax request; and it failed in engine.js with an unknown error. What we figured; we will provide the information in answer to this question. Code snippet is below, and it continue to fail on line '3' below i.e. controllerClass.someMethod call. selectObj1 and selectObj2 are array type of objects.
if (document.getElementById("someCheckBox").checked) {
//Below controllerClass is the name of JS class produced by DWR but actually it's a Java class (i.e. object used below)
controllerClass.someMethod("Value1", selectObj1, selectObj2, 'Value2', 'Value1', function(data) {
if (data != null) {
hideView("viewOne",false); //user defined function call
fillData("viewName",data[0]); //user defined function to fill the returned data
valueRet1 = data[1];
someConst = "X";
displayNavCon(pageNumber); //user defined function to control the navigation on web page
} else {
alert("No Data Found!!!");
recordCount=0;
}
});
When it comes to DWR and it start's failing with an error in engine.js; I think DWR needs to put some improvements there. Because most of the time error is/was unknown. So in above case - we were passing some data in DWR's ajax call using selectObj1 like an array and selectObj2 like an array, how data being constructed haven't changed in years; then we noticed that there was a decimal value being passed in selectObj1 that has comma in it, we removed the comma before giving data to DWR's ajax call and Bingo! it worked. Code fix is below;
Conclusion - If you see engine.js is failing, then it might not just be something wrong in your code; it could be data that it don't like or could be some other config related to DWR.