Can't use the same class in both server and client

7 views
Skip to first unread message

Abdelhamid

unread,
Feb 12, 2008, 8:42:52 AM2/12/08
to Google Web Toolkit
Hi all,

I have a bean named Account in server-side code, i don't want to add
the same class in client side so i can get by GWT RPC calls (such as
findAccountByPrimaryKey(int key)).
So I kept this class only in server-side, it implements
java.io.serializable instead of isSerializable and i added it in my
module's source path.
The project is compiled with no errors, but it fails when trying to
run it and i get the following Uncaught exception :

[ERROR] Uncaught exception escaped
java.lang.ClassCastException: isd.bcp.bali.account.bean.Account
at isd.bcp.carthago.client.GUI$1.onSuccess(GUI.java:26)
at isd.bcp.carthago.client.service.BCPService_Proxy
$1.onCompletionImpl(transient source for
isd.bcp.carthago.client.service.BCPService_Proxy:70)
at isd.bcp.carthago.client.service.BCPService_Proxy
$1.onCompletionAndCatch(transient source for
isd.bcp.carthago.client.service.BCPService_Proxy:46)
at isd.bcp.carthago.client.service.BCPService_Proxy
$1.onCompletion(transient source for
isd.bcp.carthago.client.service.BCPService_Proxy:40)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:
126)
at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:
150)
at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:
293)


Anyone have an explanation ?

Thanks a lot.
Abdelhamid

Manuel Darveau

unread,
Feb 12, 2008, 9:32:13 AM2/12/08
to Google-We...@googlegroups.com
I don't have the bug picture here but it looks like you are casting the return value from the RCP call to something but it is actually a isd.bcp.bali.account.bean.Account.

Can you send the inner class in isd.bcp.carthago.client.GUI that handle the RCP response?

Manuel

Abdelhamid

unread,
Feb 12, 2008, 10:28:08 AM2/12/08
to Google Web Toolkit
Thanks for your reply Manuel,
I found something wrong : my eclipse hosted mode jre was 1.5, I
changed it to 1.4, the previous problem is replaced by another !!
I have no runtime errors, but nothing is displayed and i get the
following warning at runtime :

[WARN] StandardWrapperValve[shell]: Servlet.service() for servlet
shell threw exception
java.lang.UnsupportedClassVersionError: isd/bcp/carthago/server/
BCPServiceImpl (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName(Class.java:141).




On Feb 12, 3:32 pm, "Manuel Darveau" <manueldarv...@gmail.com> wrote:
> I don't have the bug picture here but it looks like you are casting the
> return value from the RCP call to something but it is actually a
> isd.bcp.bali.account.bean.Account.
>
> Can you send the inner class in isd.bcp.carthago.client.GUI that handle the
> RCP response?
>
> Manuel
>

Abdelhamid

unread,
Feb 12, 2008, 10:35:28 AM2/12/08
to Google Web Toolkit
here is the inner class that handle the RPC response :

AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
isd.bcp.bali.account.bean.Account account =
(isd.bcp.bali.account.bean.Account) result;
panel.add(new Label(account.getName()));
}

public void onFailure(Throwable ex) {

}
};

Manuel Darveau

unread,
Feb 12, 2008, 1:24:37 PM2/12/08
to Google-We...@googlegroups.com
Looks like you changed the JRE but not the JDK compliance setting of your project.
In eclipse, right-click on your project and select properties.
In Java Compiler, select enable project specific settings and Use the 1.4 complicance level.

Recompile and retry to run the project. This should clear the new error.

As for the ClassCastException, can you tell me a little bit more about the project structure.
Is everything in the same project or did you split the war, rpc and server into different projects (as recommended by the maven-gwt plugin)?

Manuel
Reply all
Reply to author
Forward
0 new messages