You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ri...@xentu.com on 2017/11/25 14:35:51 UTC

where to put jars used by several apps

I've written a few jersey webapps, and each has about 20 jar files 
included as Maven dependencies.

The inclusion of those jars increases the size of the resulting wars by 
a factor of over 100. Uploading a war via 'Tomcat Web Application 
Manager' takes several minutes, presumably due in part to the war size.

Given that these webapps require the same set of jars in their 
WEB-INF/lib/, I thought I could place them in say

C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\jersey

where all webapps could find them.

In catalina.properties, I appended this new directory to the 
common.loader list of paths:

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar, 
${catalina.base}/lib/jersey/*.jar

Then, in each jersey webapp, I'd modify pom.xml to exclude those files 
from the war.

<plugin>
   <artifactId>maven-war-plugin</artifactId>
   <version>3.2.0</version>
   <configuration>
     <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
   </configuration>
</plugin>

This approach seems to work.

So, the question I'm seeking advise on is this:

If I have a collection of jars that I want to keep on Tomcat, for some 
but not all webapps, and those jars are not to be included in the wars, 
is this an acceptable technique? Or is it going to land me in trouble? 
Does the order of locations in common.loader matter?


Thanks for any advice
Richard

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: where to put jars used by several apps

Posted by ri...@xentu.com.
On 2017-11-25 14:35, richard@xentu.com wrote:
> I've written a few jersey webapps, and each has about 20 jar files
> included as Maven dependencies.
> 
> The inclusion of those jars increases the size of the resulting wars
> by a factor of over 100. Uploading a war via 'Tomcat Web Application
> Manager' takes several minutes, presumably due in part to the war
> size.
> 
> Given that these webapps require the same set of jars in their
> WEB-INF/lib/, I thought I could place them in say
> 
> C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\jersey
> 
> where all webapps could find them.
> 
> In catalina.properties, I appended this new directory to the
> common.loader list of paths:
> 
> common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,
> ${catalina.base}/lib/jersey/*.jar
> 
> Then, in each jersey webapp, I'd modify pom.xml to exclude those files
> from the war.
> 
> <plugin>
>   <artifactId>maven-war-plugin</artifactId>
>   <version>3.2.0</version>
>   <configuration>
>     <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
>   </configuration>
> </plugin>
> 
> This approach seems to work.
> 
> So, the question I'm seeking advise on is this:
> 
> If I have a collection of jars that I want to keep on Tomcat, for some
> but not all webapps, and those jars are not to be included in the
> wars, is this an acceptable technique? Or is it going to land me in
> trouble? Does the order of locations in common.loader matter?
> 
> 
> Thanks for any advice
> Richard
> 


Ray & Nasry, thanks for your observations.

Seems like my approach, in my situation at least, isn't going to cause 
me problems, so that's good.

I'm only deploying to one server & the only apps on it are ones I've 
written, so I can take care of the versions of the jars involved.

Regards
Richard





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: where to put jars used by several apps

Posted by Ray Holme <ra...@yahoo.com.INVALID>.
I see by your paths that you are an MS person. Your solution is clever but has the distribution problem that a war file may not be enough.
For Unix based folks (MAC, Linux), there is a much easier solution. Put your common jars in some directory that you like (for me /opt/web_jars/acquired). Then HARD link the jars to where you want them e.g.   ln /opt/web_jars/acquired/commons-logging-1.2.jar /opt/apache/webapps/application/WEB-INF/libThis does not solve the problem for a target machine running multiple applications, but it sure does solve the problem for a development machine with multiple applications and target machines running any one of them. War files work fine.
Your solution does have one major advantage - war fles are smaller.But if you change any of those jars, you need to distribute those changes and the war file does NOT do it.!
 

    On Saturday, November 25, 2017 9:35 AM, "richard@xentu.com" <ri...@xentu.com> wrote:
 

 I've written a few jersey webapps, and each has about 20 jar files 
included as Maven dependencies.

The inclusion of those jars increases the size of the resulting wars by 
a factor of over 100. Uploading a war via 'Tomcat Web Application 
Manager' takes several minutes, presumably due in part to the war size.

Given that these webapps require the same set of jars in their 
WEB-INF/lib/, I thought I could place them in say

C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\jersey

where all webapps could find them.

In catalina.properties, I appended this new directory to the 
common.loader list of paths:

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar, 
${catalina.base}/lib/jersey/*.jar

Then, in each jersey webapp, I'd modify pom.xml to exclude those files 
from the war.

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <version>3.2.0</version>
  <configuration>
    <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
  </configuration>
</plugin>

This approach seems to work.

So, the question I'm seeking advise on is this:

If I have a collection of jars that I want to keep on Tomcat, for some 
but not all webapps, and those jars are not to be included in the wars, 
is this an acceptable technique? Or is it going to land me in trouble? 
Does the order of locations in common.loader matter?


Thanks for any advice
Richard

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



   

Re: where to put jars used by several apps

Posted by Nasry Al-Haddad <al...@gmail.com>.
One issue you might face in this configuration is if you have multiple versions of the same library existing on the same path, let's say com.example v1.0 and v2.0, and each is a dependency for one or more webapps. If a webapp depending on 2.0 requires class com.example.X which is available in both versions, and if the class loader looks in v1.0 jar file first, then you might see some CNF exceptions and such.

To workaround this ensure both statements below are true:
1. The class loader searches in WEB-INF jar files before common.loader (I think it should be the case)

2. Update your build process to include in WEB-INF only jar files that have an older version in common.loader path (just to not break any webapp especially the one being installed).

If you end up updating all webapps to use the latest version of the library com.example, you'll end up with all webapps having the latest version in WEB-INF and the unused older version in common.loader path. Then update the common.loader path by removing the old version and adding the new one, and remove it from WEB-INF directories.

This might incur more work on managing the webapps. But if you could have an automated build process that decides where to put dependency jar files and have it as a step for all webapps builds, then it could be a time/space saver later.

⁣Regards,
Nasry Al-Haddad

Sent from BlueMail ​

On Nov 25, 2017, 16:35, at 16:35, richard@xentu.com wrote:
>I've written a few jersey webapps, and each has about 20 jar files 
>included as Maven dependencies.
>
>The inclusion of those jars increases the size of the resulting wars by
>
>a factor of over 100. Uploading a war via 'Tomcat Web Application 
>Manager' takes several minutes, presumably due in part to the war size.
>
>Given that these webapps require the same set of jars in their 
>WEB-INF/lib/, I thought I could place them in say
>
>C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\jersey
>
>where all webapps could find them.
>
>In catalina.properties, I appended this new directory to the 
>common.loader list of paths:
>
>common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,
>
>${catalina.base}/lib/jersey/*.jar
>
>Then, in each jersey webapp, I'd modify pom.xml to exclude those files 
>from the war.
>
><plugin>
>   <artifactId>maven-war-plugin</artifactId>
>   <version>3.2.0</version>
>   <configuration>
>     <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
>   </configuration>
></plugin>
>
>This approach seems to work.
>
>So, the question I'm seeking advise on is this:
>
>If I have a collection of jars that I want to keep on Tomcat, for some 
>but not all webapps, and those jars are not to be included in the wars,
>
>is this an acceptable technique? Or is it going to land me in trouble? 
>Does the order of locations in common.loader matter?
>
>
>Thanks for any advice
>Richard
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org