TOMCAT DEPLOYMENT: HOW DO I ADD FIXED PATH EXTERNAL JAR TO TOMCAT CLASSPATH/CLASSLOADER

2,164 views
Skip to first unread message

Joseph M

unread,
Apr 16, 2008, 2:08:11 PM4/16/08
to Google Web Toolkit
I have a slightly unusual problem in that I have a set of drivers with
some dependencies and copy protections which prevent me from moving
the relevant jar files from their install directory and into the /WEB-
INF/ directory in my Tomcat deployment nor into $CATALINA_HOME/common/
lib. I did some searching but nothing seems to answer the question
for me.

I am currently developing in Eclipse, my ap which references the
external jars in the Build Path runs fine in Hosted Mode.

I have been struggling with this for a while and would like to finally
deploy my application and not sit in Hosted Mode all the time.

By the way, I deploy my aps so far by copying the compiled www folder
and manually reconsructing the /WEB-INF/ directory. I am not very
well versed in ant nor in making WARs.

I will be eternally grateful to whomever can help me with this.

Cheers,
Joe

gregor

unread,
Apr 16, 2008, 2:45:56 PM4/16/08
to Google Web Toolkit
Search group for "ant build war" - you'll find plenty of examples.

regards
gregor

Joseph M

unread,
Apr 16, 2008, 4:44:48 PM4/16/08
to Google Web Toolkit
Is using a War constructed with an Ant build the only way??? If not
how else can this be done?

Joseph M

unread,
Apr 16, 2008, 7:10:20 PM4/16/08
to Google Web Toolkit
To further elaborate, the jar is only needed by the servlet. The
client has no direct connection or need of the external jar

gregor

unread,
Apr 16, 2008, 8:03:52 PM4/16/08
to Google Web Toolkit
using an war build ant script is by far the easiest way to manage
deployment, but if you already have your files arranged in Tomcat by
other means, place your jar file in the WEB-INF/lib directory.

regards
gregor

walden

unread,
Apr 17, 2008, 7:32:54 AM4/17/08
to Google Web Toolkit
Joe,

Concerning the jar file you are not allowed to copy, It is possible to
configure Tomcat to load context from anywhere on your drive. The
'webapps' thing is just a convention. Consult the tomcat docs.

Walden

Greg Hellings

unread,
Apr 16, 2008, 4:59:31 PM4/16/08
to Google-We...@googlegroups.com
On Wed, Apr 16, 2008 at 3:44 PM, Joseph M <duocen...@gmail.com> wrote:
>
> Is using a War constructed with an Ant build the only way??? If not
> how else can this be done?

In $TOMCAT_HOME/bin/catalina.sh you will find that the system mangles
the CLASSPATH by adding a few more .jar files to it at startup for
the server. This is, no doubt, to add in the libraries that the
Tomcat system uses. It's a horrible hack, but if you really are
completely unable to move things into your WEB-INF/ folder, then you
could probably do some additional mangling of that catalina.sh file to
add your jars to the classpath.

As noted, this is a hideous hack, because then you're without any sort
of portability and can't really deploy it outside of your own Tomcat
installation. You'd do much better to work with putting the files
into your WEB-INF directory, no matter how messy that might become,
rather than manipulating your Tomcat installation.

--Greg

Joseph M

unread,
Apr 17, 2008, 1:59:18 PM4/17/08
to Google Web Toolkit
Greg,
I am unfortunately stuck in Windows since that is what this copy-
protected external jar is located in and I am convinced that the WEB-
INF just isnt an option. Would it make sense then to add my packages
and jar to the $TOMCAT_HOME/conf/catalina.properties ?

In there we have:

pakage.access
package.definition
common.loader
server.loader
shared.loader

Which ones should I add my external jars to?

Thanks,
Joseph


On Apr 16, 4:59 pm, "Greg Hellings" <greg.helli...@gmail.com> wrote:

gregor

unread,
Apr 17, 2008, 3:07:28 PM4/17/08
to Google Web Toolkit
Hi Joseph,

I think you might be on the wrong track here. IMHO you should not
include any jar in your app (by whatever means) that someone else has
arbitrary control over. You should copy a suitable version of it to
your e.g /lib/* directory and use that in your WAR build. If,
however, your app is dependent on services provided in said jar and
you have no control over it (i.e. it may be changed at any time), then
you need to tell us more for hope of better advice.

However, on the assumption that the jar you're referring to is a
controlled artifact (and not by you), I think your best approach maybe
to make an ant task to build your app (into a WAR) , get hold of the
main build file for the jar, add your task to it, demonstrate it
works, and get it accepted in the overall build (i.e. included in the
mainline EAR). This is I think preferred to ferreting around for the
main jar on the app server on the fly.

regards
gregor

Joseph M

unread,
Apr 17, 2008, 4:56:04 PM4/17/08
to Google Web Toolkit
Thanks Gregor,
Sadly as I said my experience with Ant and WARs is limited but I guess
I will just have to learn it. Thanks for your help everyone. I am
sure I will be writing some more questions after putting significantly
more time into learning ant.

Cheers
Joseph
Reply all
Reply to author
Forward
0 new messages