How to add /usr/share/java libs to webapp's classpath?

You should not do that. JEE applications are the supposed to be self sufficient and not depend on any resources outside the deployment package other than those provided by the container. So you should take the libs you need from that directory and add it to your war or ear package.

You should not do that. JEE applications are the supposed to be self sufficient and not depend on any resources outside the deployment package other than those provided by the container. So you should take the libs you need from that directory and add it to your war or ear package.

This guarantees that your application will behave the same wherever you deploy it and you will not be subject to unexpected changes in the versions of the libs in /usr/share/java....

I can see the reason in your answer and even can agree with you. The problem this leads to huge . Deb packages and clearly against linux distros packaging ideology.

I tend to think about . Jar the same way as about . So files.

Does this mean linux distros just not well suited for packaging web apps? – Yurii Soldak Sep 22 '08 at 15:34 I've decided symlink concrete jars into webapp's lib directory and depend on concrete versions of libraries to ensure changes in /usr/share/java do not affect my app (see more detailed description in my answer to this question) – Yurii Soldak Sep 25 '08 at 13:14.

According to the Tomcat classloading documentation, you need to put any shared libs that should be available to all Tomcat apps in the $CATALINA_BASE/shared/lib library -- so one way to do what you're looking to do is to move your libraries from /usr/share/java to $CATALINA_BASE/shared/lib. BUt if I'm not misunderstanding that same documentation, Tomcat also makes the system-wide CLASSPATH variable's contents available to the classloader at launch, so if your directory -- /usr/share/java -- were included in the system-wide CLASSPATH variable, then that should work too. I've never done this, though; Tomcat's method of making the contents of $CATALINA_BASE/shared/lib available Tomcat-wide has always served me perfectly.

You have two options, one is to let the classloader provide the libraries to all java programs and the other is to let the classloader provide the libraries to all tomcat contexts. Add your symlinks to /usr/lib/jvm/java-1.5.0-sun-1.5.0.11/jre/lib (note you may need to specify a different version in this path) to allow all java programs access to these libraries or add them to Tomcat's shared libraries at var/lib/tomcat5.5/shared/libs (again, the version number may be different) for access by all Tomcat contexts. I should also note that these directory locations were taken from Ubuntu "Feisty".

Entzik's answer lead me to the following solution. I'm going to use modified "bad solution" (see question). Modifications are following: Depend on specific package version for all dependencies (affects "control" file while packaging for deb)example: libcommons-io-java ( = 1.3.1) instead of just libcommons-io-java Symlink to actual jar files in `/usr/share/java` and not "generalized" onesexample: webdir/WEB-INF/lib/commons-io.

Jar -> /usr/share/java/commons-io-1.3.1. Jarand notwebdir/WEB-INF/lib/commons-io. Jar -> /usr/share/java/commons-io.

Jar This modifications ensure webapp is not broken if administrator installed new version of a library (commons-io for example). The downside is this approach clearly inflates system with used-by-only-one-app versions of libraries and may lead to problem some other application/library can't install due to version conflict. I guess both potential problems are minor if we are speaking about libraries.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions