RPC and server side classes

18 views
Skip to first unread message

Mike Dee

unread,
Aug 3, 2011, 1:57:28 PM8/3/11
to Google Web Toolkit
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

Juan Pablo Gardella

unread,
Aug 3, 2011, 2:29:57 PM8/3/11
to google-we...@googlegroups.com
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 <mdichi...@gmail.com>

--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Mike Dee

unread,
Aug 3, 2011, 2:38:15 PM8/3/11
to Google Web Toolkit
I added a .gwt.xml file to the OldProject and inherited it from
NewUiProject. Only the data objects (pojos) from the OldProject are
listed in the source path of the .gwt.xml.


On Aug 3, 11:29 am, Juan Pablo Gardella <gardellajuanpa...@gmail.com>
wrote:
> 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 <mdichiapp...@gmail.com>

Juan Pablo Gardella

unread,
Aug 3, 2011, 2:49:41 PM8/3/11
to google-we...@googlegroups.com
java.lang.NoClassDefFoundError: [Lcom/mycompany/myproject/data/FooDataClass; is not the same ClassNotFoundException, so perhaps you have a dependency or is not serializable or instanciable in runtime.

Is serializable? have final fields? have a default constructor?




2011/8/3 Mike Dee <mdichi...@gmail.com>

Mike Dee

unread,
Aug 3, 2011, 3:29:31 PM8/3/11
to Google Web Toolkit
Juan, I thought you may have found the problem. There was a static
variable, the old:

static final long serialVersionUID = -1L;

I removed it, but that didn't make a difference.

Could it be that the data classes from the OldProject are really not
being picked up in NewUiProject? I tried doing a GWTCompile and
looking at the output. I don't see classes from OldProject in the WAR
for NewUiProject...even when I include the OldProject.jar! But, maybe
I don't understand enough about how GWT works?

Mike


On Aug 3, 11:49 am, Juan Pablo Gardella <gardellajuanpa...@gmail.com>
wrote:
> java.lang.NoClassDefFoundError: [Lcom/mycompany/myproject/data/FooDataClass;
> is not the same
> ClassNotFoundException<http://stackoverflow.com/questions/1457863/what-is-the-difference-bet...>,
> so perhaps you have a dependency or is not serializable or instanciable in
> runtime.
>
> Is serializable? have final fields? have a default constructor?
>
> 2011/8/3 Mike Dee <mdichiapp...@gmail.com>

Juan Pablo Gardella

unread,
Aug 3, 2011, 4:03:40 PM8/3/11
to google-we...@googlegroups.com
This static variable isn't affect. You must put oldproject jar in WEB-INF/lib, isn't run in dev mode?

2011/8/3 Mike Dee <mdichi...@gmail.com>

Mike Dee

unread,
Aug 3, 2011, 6:55:31 PM8/3/11
to Google Web Toolkit
Yep, that seems to have fixed it.

Thanks,
Mike

On Aug 3, 1:03 pm, Juan Pablo Gardella <gardellajuanpa...@gmail.com>
wrote:
> This static variable isn't affect. You must put oldproject jar in
> WEB-INF/lib, isn't run in dev mode?
>
> 2011/8/3 Mike Dee <mdichiapp...@gmail.com>
Reply all
Reply to author
Forward
0 new messages