Wednesday, August 3, 2011

Re: RPC and server side classes

RPC only work as transport layer between client and server side, so you must put old project as a jar and define *.gwt.xml inside and define the module. In NewUiProject inherit it. You can't said that the POJO is only in server side if RPC layer try serialize/deseralize

Juan

2011/8/3 Mike Dee <mdichiappari@gmail.com>
I'm updating an existing web app to use GWT and encountering a problem
on server side.  A goal is to reuse the server side data classes,
which are stored in a separate Eclipse project.

I have two projects: OldProject, which has old data classes (as POJOs)
and NewUiProject, which is GWT.

If I put the OldProject POJOs in the NewUiProject, all is fine.  Of
course the POJOs don't fall under the "shared" directory, so I created
a .gwt.xml file and inherited that into the NewUiProject .gwt.xml.

If the OldProject POJOs are left in their project and NewUiProject
inherits the .gwt.xml from OldProject a runtime error occurs.

[ERROR] javax.servlet.ServletContext log: Exception while dispatching
incoming RPC call
java.lang.NoClassDefFoundError: [Lcom/mycompany/myproject/data/
FooDataClass;
       at java.lang.Class.getDeclaredMethods0(Native Method)
       at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
       at java.lang.Class.getMethod0(Unknown Source)
       at java.lang.Class.getMethod(Unknown Source)
       at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:299)
       at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
206)
       at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
248)
       at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
62)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

It looks like FooDataClass is simply not found on the server side and
I can't figure out why.  I am using Eclipse and NewUiProject has a
project reference to OldProject and also includes OldProject in the
Java Build Path Projects.  If there were a project with references
across projects I don't think the project would compile.  I also tried
packaging a JAR from OldProject and including it in NewUiProject, but
that makes no difference.

I don't think this is a case of not inheriting classes so that GWT
knows to compile them in the client side.  That would produce an error
when starting up the client and an error message about not being able
to find the source code for the data classes. I'm mot seeing that
error.  The UI comes up and the error is thrown when interacting with
the UI in such a way as to cause an RPC.

Any ideas?

Thanks,
Mike

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment