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