Keep getting ClassNotFoundException for a server-side class from inherited project?

76 views
Skip to first unread message

markww

unread,
Nov 24, 2012, 4:40:24 PM11/24/12
to google-we...@googlegroups.com
Hi,

I have a gwt project, called "base". It has a class in its "server" package, Foo.java:

    com.me.test.server.Foo;

I have another gwt project called "zebra", which references project "base". This is done in eclipse, in the Java Build Path settings.

I'm trying to use the Foo class server-side in the "zebra" project. Both projects compile and deploy fine, but "zebra" throws a ClassNotFoundException for the Foo class when I try to use it at runtime (all server side).

I chose the option in eclipse to export "base" (in the Order and Export settings), but still no luck. The "zebra" project also imports "base" via the gwt module xml file, but I don't think that matters here since this is server-side code. All the clientside classes that are inherited from "base" work fine:

    // in zebra's gwt.xml file:
    <inherits name='com.me.test.Base' />

Do we need a special directive to get "zebra" to also include the server classes from "base" when it is deployed? Everything compiles fine.

Thank you

markww

unread,
Nov 24, 2012, 5:05:32 PM11/24/12
to google-we...@googlegroups.com
Ok the error was a dependent class that wasn't in the /shared folder. I set the gwt compile log level to "all", and then in there searched for errors, which pointed to it:

Validating units:
      Errors in 'file:/src/com/me/test/shared/Foo.java'
         Line 72: No source code is available for type Bar; did you forget to inherit a required module?

I thought these used to block compilation, I can't remember.

Thanks

markww

unread,
Nov 24, 2012, 5:51:21 PM11/24/12
to google-we...@googlegroups.com
Actually I spoke too soon, now getting the error again.

    // base project
    com.me.test.server.Foo

    // other project (zebra)
    com.me.zebra.server.Bar


And Bar.java looks like:

    class Bar extends Foo {
    }

compiles fine in eclipse, and the GWT compilation process reports no errors. However now as soon as I deploy to a local server instance via eclipse (Run As -> Web Application) I get a NoClassDefFoundError exception:

    java.lang.NoClassDefFoundError: com/me/test/server/Foo
        at java.lang.ClassLoader.defineClass1(Native Method)
        ...

stumped here - gwt compile shows no problems, and I have the base project marked as exported in the zebra project which uses it. Any ideas what's going on here? It just seems like the class file for Foo is not getting exported with the deploy,

Thanks

markww

unread,
Nov 26, 2012, 12:23:57 AM11/26/12
to google-we...@googlegroups.com
So I couldn't get this to work by using project references in eclipse. Project references work fine for client-side code. My two projects again look like:

    ProjectBase
    ProjectZebra

so in eclipse, I linked the "src" folder of "ProjectBase" from ProjectZebra. I gave it a name like "src-ProjectBase". Then eclipse can do its local compiles ok, and deploys now work ok with it too (both clientside and serverside code).

Thanks



On Saturday, 24 November 2012 16:40:24 UTC-5, markww wrote:
Reply all
Reply to author
Forward
0 new messages