NoClassDefFoundError

16 views
Skip to first unread message

todd....@gmail.com

unread,
Apr 8, 2008, 11:54:33 AM4/8/08
to Google Web Toolkit
Using GWT 1.5 M1 I am getting the following error:
=================================
[ERROR] Unable to load module entry point class
com.knowledge_advantage.myka.userportal.client.GapEditorTester (see
associated exception for details)
java.lang.NoClassDefFoundError: org/apache/jackrabbit/ocm/manager/
collectionconverter/ManageableCollection
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
at
com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:
497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at
com.knowledge_advantage.myka.userportal.client.GapEditorTester.onModuleLoad(GapEditorTester.java:
14)
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)
=================================

I am also getting tons of warning about resolving annotations. Is
there a way to add the Jackrabbit source to my project? If not can I
create something like the JRE emulation library to allow for
compilation?

Ian Petersen

unread,
Apr 8, 2008, 1:27:39 PM4/8/08
to Google-We...@googlegroups.com
On Tue, Apr 8, 2008 at 11:54 AM, todd....@gmail.com
<todd....@gmail.com> wrote:
> I am also getting tons of warning about resolving annotations. Is
> there a way to add the Jackrabbit source to my project? If not can I
> create something like the JRE emulation library to allow for
> compilation?

What is Jackrabbit? If its use of the JRE is limited to those classes
emulated by GWT, then you should be able to just put its source on
your project's classpath and the GWT compiler should just pick it up.
If Jackrabbit uses parts of the JRE that are not emulated then you'll
either need to add the missing bits of the JRE or port the part of
Jackrabbit that you're using to GWT. Since adding Jackrabbit's source
to your classpath is the easiest, I'd start there and see if it "just
works".

In general, to add an external project to your GWT app, you need to
find a way to get the external project's source into the compiler's
classpath at compilation time, and you need make sure that the parts
you're using are in the collection of translatable directories, as
specified by your GWT module. For example, your project tree probably
looks something like this (which is the default for an Eclipse
project, I think):

/src
/com
/example
MyModule.gwt.xml
/gwtapp
/client
... translatable Java files
/public
... web resources like the host HTML page, etc.
/server
... server-side Java files that need not be translatable
/bin
... compiled output of the above

In the above situation, your module file
(com/example/MyModule.gwt.xml) need not have a <source> directive
because your project is set up in the default configuration so you may
not realize that you can use <source path="..." /> to add directories
to the set of directories that contain translatable source. The path
specified in the source tag is relative to the module file so the
default can be made explicit with <source path="client" />. If you
add a <source> tag to your module definition, it overrides the default
assumption that there is translatable source in the client directory,
so, if you want to have translatable source in multiple directories,
including the client directory, you'll have to add <source> tags for
all non-default directories _plus_ one for the client directory.

Now then, the ideal situation for adding external code to a project
like the above is if the external code is already a GWT module. Then
you just put the relevant JARs on your classpath and add an <inherits>
tag to your module to tell the GWT compiler to go look for the new
module. I doubt Jackrabbit is a GWT module, so you'll have to make it
one. The easiest way to do that is to add the following structure to
your existing project:

/src
/com
... this is your existing source tree
/org
/apache
Jackrabbit.gwt.xml

You'll also want to modify your build scripts (so any Ant script you
might have, your Eclipse launch configurations, maybe the shell script
that GWT's applicationCreator creates for you, whatever) so that
building or running your project references the binaries and source
for the Jackrabbit project on the classpath. Now, in the
Jackrabbit.gwt.xml module descriptor, you need to specify a <source>
tag that tells the GWT compiler which parts of the org.apache
namespace to make translatable. If you want _all_ of Jackrabbit, do
this:

<module>
<source path="jackrabbit" />
</module>

If you just want a piece of it do something like this:

<module>
<!-- this assumes you only need the package mentioned in your error report -->
<source path="jackrabbit/ocm/manager/collectionconverter" />
</module>

If need two or more parts of Jackrabbit, do this:

<module>
<source path="jackrabbit/path/to/part/one" />
<source path="jackrabbit/path/to/part/two" />

<!-- I think you can also use ant-like path descriptions so that you can
specify multiple directories in one source tag, but I've never
done that -->
</module>

Then, in the main module descriptor for your project, add this:

<inherits name="org.apache.Jackrabbit" />

and recompile/reload.

If you run into trouble with unresolvable references, either to parts
of the JRE that aren't emulated or external libraries that Jackrabbit
depends on, you'll need to make a decision. One choice is to try
paring down the <source> tags in Jackrabbit.gwt.xml so that you're
specifying the minimal set of translatable directories possible
because this increases the chances that the compiler can complete
without running into an untranslatable file or reference. Another
choice is to try and satisfy the references, either by writing some
code to further emulate the JRE (kind of a pain, and perhaps
impossible, depending on which part of the JRE we're talking about),
or by adding more source to the classpath. Finally, if neither of the
first two choices work, you can try to port Jackrabbit to GWT, which
basically means copying the source into your project and whittling it
down to the minimum that you need and that is compatible with GWT.

Frankly, porting something to GWT can be a big hassle (although the
situation has improved now that GWT supports Java 1.5 syntax), and
adding to the emulated JRE is a bigger hassle (there are reasons why
the JRE emulation is as limited as it is, so extending it can be an
uphill battle, depending on which part you tackle). If adding a
reference to Jackrabbit, as outlined above, doesn't work, you should
consider replacing Jackrabbit with a work-alike before jumping in to a
porting effort, unless you have a lot of time on your hands.

HTH,
Ian

PS If any of the above description of module files is unclear, you
might want to have a look at
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.html
and, in particular,
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.html#Modules
to see if the documentation makes things any clearer.

--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com

gregor

unread,
Apr 8, 2008, 2:28:29 PM4/8/08
to Google Web Toolkit
I've started using jackrabbit very recently for a new project so I'm
very unsure about it's innards from a GWT point of view at the moment
(NB: Peter, jackrabbit is Apache reference implementation for JCR
(Content Repository for Java Technology API - JSR 170 & 283)

Whereas Swing/SWT client could easily use the jackrabbit API over RMI,
preliminary scans of returned objects in my debugger suggest most of
them are unlikely to be compatible with GWT JRE Emulation per Peter
above. My first approach is to make my own POJO classes to represent
content in my GWT application and use something similar to DAO pattern
to read them in and out of repository. The POJO's themselves have no
reference to jackrabbit classes, so they are GWT JRE compatible and I
can use them freely client side. I Don't know how well this will work
out yet as I'm still struggling a bit to get my head round jackrabbit.

There is no problem using jackrabbit jars in the GWT RPC servlet layer
only of your project - just add them to classpath.

regards
gregor


On Apr 8, 6:27 pm, "Ian Petersen" <ispet...@gmail.com> wrote:
> On Tue, Apr 8, 2008 at 11:54 AM, todd.sei...@gmail.com
> might want to have a look athttp://code.google.com/webtoolkit/documentation/com.google.gwt.doc.De...
> and, in particular,http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.De...

todd....@gmail.com

unread,
Apr 8, 2008, 2:52:01 PM4/8/08
to Google Web Toolkit
Thank you for responding so soon and with such detail. It has been
very useful.

Jackrabbit is ASF's version of a JSR170 Content Repository. Projects
like OpenKM use it. They recently added Object Content Mapping (OCM)
using annotations.

The annotations only cause a bunch of warning in GWT which seem to
cause no real problem. The only problem that I ran into is that
Jackrabbit requires any Collection type which is mapped to the
repository to implement a trivial interface ManageableCollection.

I was able to download the source for Jackrabbit and add it to the
project. Since I only care about ManageableCollection at this point, I
removed everything but this interface and followed your directions. It
works perfectly. Thanks again, Ian.

On Apr 8, 1:27 pm, "Ian Petersen" <ispet...@gmail.com> wrote:
> On Tue, Apr 8, 2008 at 11:54 AM, todd.sei...@gmail.com
Reply all
Reply to author
Forward
0 new messages