2
votes

I'm using GWT (currenly working with google's eclipse plugin), and I'm trying to throw an exception from the server to the client.

My exception is something like

class LoginException extends Exception implements IsSerializable

But I get (upon loading in hosted mode):

[ERROR] Errors in '[...]/src/myPackage/client/services/Session.java'

[ERROR] Line 25: No source code is available for type hugobarrera.gestorAlumnos.server.LoginException; did you forget to inherit a required module?

Session.java is:
[...]

public interface Session extends RemoteService {

[...] (Line 25:)

String newSession(String usr, String pwd) throws LoginException;

[...]

Where am I going wrong? I've read like a MILLION places where people have problems with throwing exceptions, but none of those solutions applied.

2
Is LoginException in the same java package and project as the Session interface? - skaffman
It wasn't. Moving it to the same package solved the problem. Also, moving it to [...]services.exceptions also works :) You should post this as an answer rather than a comment (= - WhyNotHugo

2 Answers

4
votes

All classes that need to be serialized must be in the [...].client package or a sub package.

Apparently they may not have a constructor either.
[edit] You need to have a no-argument constructor in the serializable classes.

2
votes

skaffman: LoginException was not in the same package as Session.

Hugo: Moving them to the same package solved the problem.