tomcat lib folder and subfolders

G

grasp06110

Hi Everybody!

Is there a way to get tomcat to look at jar files in subfolders of the
<TOMCAT_HOME>/webapps/myApp/WEB-INF/lib folder? Everyone seems to
just dump everything into this folder directly which makes it kind of
hard to keep things organized (especially when one component/api/unit
is swapped out for another).

Thanks,
John
 
A

Arne Vajhøj

grasp06110 said:
Is there a way to get tomcat to look at jar files in subfolders of the
<TOMCAT_HOME>/webapps/myApp/WEB-INF/lib folder? Everyone seems to
just dump everything into this folder directly which makes it kind of
hard to keep things organized (especially when one component/api/unit
is swapped out for another).

No.

Not by the servlet spec.

And not by standard Tomcat.

I would be really surprised if you app had so many jar files, that it
would be necesarry.

Arne
 
F

freddy

Hi Everybody!

Is there a way to get tomcat to look at jar files in subfolders of the
<TOMCAT_HOME>/webapps/myApp/WEB-INF/lib folder?  Everyone seems to
just dump everything into this folder directly which makes it kind of
hard to keep things organized (especially when one component/api/unit
is swapped out for another).

Thanks,
John

If you have a lot of host then i would just put the commonly used
stuff like jdbc drivers, jstl, and other commonly used stuff. anything
else i would have included with the app WEB-INF/lib.
 
O

Owen Jacobson

Hi Everybody!

Is there a way to get tomcat to look at jar files in subfolders of the
<TOMCAT_HOME>/webapps/myApp/WEB-INF/lib folder? Everyone seems to
just dump everything into this folder directly which makes it kind of
hard to keep things organized (especially when one component/api/unit
is swapped out for another).

Thanks,
John

If you have enough libraries in there that this is a problem, consider
using real dependency management to build your WAR file. Maven
(http://maven.apache.org/) or Ivy (http://ant.apache.org/ivy/) can,
from a list of dependencies that your code directly uses, dump out all
the JARs that need to go in lib, saving you from having to organize it
by hand.

-o
 
A

Arne Vajhøj

If you have enough libraries in there that this is a problem, consider
using real dependency management to build your WAR file. Maven
(http://maven.apache.org/) or Ivy (http://ant.apache.org/ivy/) can, from
a list of dependencies that your code directly uses, dump out all the
JARs that need to go in lib, saving you from having to organize it by hand.

I read the question as if he wanted to divide the deployment
lib directory - not the source lib directory.

Arne
 
O

Owen Jacobson

I read the question as if he wanted to divide the deployment
lib directory - not the source lib directory.

There's a difference?

Aside from the EE API classes (javax.servlet.* and friends), the WAR's
runtime library set is a superset of the compile-time library set.
Except for container-managed resources, the JARs for those go inside
the app -- and under Tomcat's default configuration, wind up unpacked
to <TOMCAT_HOME>/webapps/myApp/WEB-INF/lib/ .

-o
 
A

Abhijat Vatsyayan

grasp06110 said:
Hi Everybody!

Is there a way to get tomcat to look at jar files in subfolders of the
<TOMCAT_HOME>/webapps/myApp/WEB-INF/lib folder? Everyone seems to
just dump everything into this folder directly which makes it kind of
hard to keep things organized (especially when one component/api/unit
is swapped out for another).

Thanks,
John
If you stick to the servlet specification, the web application container
should load jars only from the lib directory. If Tomcat is the only
container you will ever use, you can always change its
WebAppClassLoader. While its pretty easy to change, I see little
advantage in doing this. Not just in terms of not following the standard
and tying yourself to a single container but also in terms of what you
are trying to achieve to begin with. If you do not keep your
dependencies clean, well defined and under contorl, pretty soon you
will end up with multiple versions of jars and duplications inside the
WEB-INF/lib/XXX directories as well.

Abhijat
 
I

iryndin

Hi Everybody!

Is there a way to get tomcat to look at jar files in subfolders of the
<TOMCAT_HOME>/webapps/myApp/WEB-INF/lib folder?  Everyone seems to
just dump everything into this folder directly which makes it kind of
hard to keep things organized (especially when one component/api/unit
is swapped out for another).

Thanks,
John

Yes, there is a way. You should write your own ClassLoader for Tomcat,
and make Tomcat use this ClassLoader.
FYI, Tomcat 6 uses several class loaders, see
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
Here I don't want dig into details, but this is certainly a way to
solve the problem.

Best regards, Ivan.
java dev blog: http://jdevnotes.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top