Monday, November 17, 2008

GWT RPC Exceptions

So... Most of GWT's documentation is pretty good, but the part about RPC exceptions is kind of lacking.

I found some posts such as:

But all of them mentioned the now deprecated SerializableException. According to the API this was deprecated because Exception implements Serializable, and thus a normal exception should work fine... (

Unfortunately I was still getting the "the call failed on the server see server log for details" message from exceptions that reached the client.

Anyway, the solution I reached was very, very, simple. My ServiceImpl class throws a standard RuntimeException ("throw new RuntimeException("Epic Fail");"). But this is what I was already doing that didn't work. I had to add "throws Exception" to the method, and thus the client side service interface as well. Worked like a charm after that.

public interface SomeService extends RemoteService {
void doSomething(Object someObject) throws exception;

public interface SomeServiceAsync {
void doSomething(Object someObject, AsyncCallback callback);

public class SomeServiceImpl extends RemoteServiceServlet implements SomService {
public void doSomething(Object someObject) throws Exception {
throw new RuntimeException("Epic Fail");

No comments: