Dojo

Marshalling errors in lists do not get propagated to the client

#1

Hi,
when i have a marshalling error inside an object in a list it is silently ignored contrary to the bahaviour of a marshalling error in a single object.
I except to also get an “Error marshalling data. See the logs for more details.” or get the DWR error handler triggered. But that is not the case. Instead i get a result list with a null entry and the server logs the following warning (not error) to the server log:

[org.directwebremoting.convert.CollectionConverter] [WARN ] - Conversion error for java.util.Arrays$ArrayList.
org.directwebremoting.ConversionException: Error marshalling data. See the logs for more details.
	at org.directwebremoting.extend.PropertyDescriptorProperty.getValue(PropertyDescriptorProperty.java:74)
	at org.directwebremoting.convert.BasicObjectConverter.convertOutbound(BasicObjectConverter.java:298)
	at org.directwebremoting.impl.DefaultConverterManager.convertOutbound(DefaultConverterManager.java:441)
	at org.directwebremoting.convert.CollectionConverter.convertOutbound(CollectionConverter.java:213)
	at org.directwebremoting.impl.DefaultConverterManager.convertOutbound(DefaultConverterManager.java:441)
	at org.directwebremoting.extend.ScriptBufferUtil.createOutput(ScriptBufferUtil.java:68)
	at org.directwebremoting.dwrp.BaseCallHandler$CallScriptConduit.addScript(BaseCallHandler.java:485)
	at org.directwebremoting.dwrp.BaseCallHandler.marshallOutbound(BaseCallHandler.java:345)
	at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:105)
	at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)
	at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:141)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: fail
	at MyRemoteService$MyDto.getProp(MyRemoteService.java:19)
	at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.directwebremoting.extend.PropertyDescriptorProperty.getValue(PropertyDescriptorProperty.java:70)
	... 31 more

Here is the code to reproduce it with DWR version 3.0.0 RC2-final:

MyRemoteService.java

import java.util.Arrays;
import java.util.List;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProperty;
import org.directwebremoting.annotations.RemoteProxy;

@RemoteProxy
public class MyRemoteService {

	@DataTransferObject
	public static class MyDto {
		@RemoteProperty
		public String getProp() {
			if(true) {
				throw new RuntimeException("fail");
			}
			return "success";
		}
		
	}
	
	
	// Works as expected (throws an error to the client)
	@RemoteMethod
	public MyDto getSingleObject() {
		return new MyDto();
	}
	
	// Does not throw an error to the client (just logs a warning) !
	@RemoteMethod
	public List<MyDto> getList() {
		return Arrays.asList(new MyDto());
	}

}

WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>myWebapp</display-name>  
  <servlet>
	<description>DWR controller servlet</description>
	<servlet-name>DWR controller servlet</servlet-name>
	<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
	<init-param>
	  <param-name>debug</param-name>
	  <param-value>false</param-value>
	</init-param>
	<init-param>
	  <param-name>crossDomainSessionSecurity</param-name>
	  <param-value>true</param-value>
	</init-param>
	<init-param>
	  <param-name>allowScriptTagRemoting</param-name>
	  <param-value>false</param-value>
	</init-param>
	<init-param>
	  <param-name>maxCallCount</param-name>
	  <param-value>1000000</param-value>
	</init-param>
	<init-param>
	  <param-name>classes</param-name>
	  <param-value>
				MyRemoteService,
				MyRemoteService$MyDto    
	  </param-value>
	</init-param>
  </servlet>
  <servlet-mapping>
	<servlet-name>DWR controller servlet</servlet-name>
	<url-pattern>/dwr/*</url-pattern>
  </servlet-mapping>
  <session-config>
	<session-timeout>2280</session-timeout>
  </session-config>
</web-app>

dwr.xml

<!DOCTYPE dwr PUBLIC
	"-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN"
	"___http://directwebremoting.org/schema/dwr30.dtd">

<dwr>
  <allow>      
	
   
	
	<!-- Also convert exceptions, so debugging is easier -->
	<convert match="java.lang.Exception" converter="exception"/>
	<convert match="java.lang.StackTraceElement" converter="bean"/>    
  </allow>
</dwr>

In the javascript console:

MyRemoteService.getSingleObject() -> triggers errohandler
MyRemoteService.getList(function(result) {console.log(result)})
>[null]
#2

Please test and see if you can reproduce with the latest version of DWR which is 3.0.2.

If the problem persists I will help you look into it.

#3

Its the same with 3.0.2.
Only little difference ist that client side error reporting from call does not show an alert window anymore (just traces to js console)

#4

Ok I will look into this!

1 Like
#5

I’ve verified the problem and created an issue for it:

Thanks for the report!

1 Like
#6

The issue is now fixed and will be part of DWR 3.0.3 later this year.