Best way of sharing JARS

Hi guys!

I’d like to have your opinions on pros and cons of these two ways to share JARs across multiple projects in
Tomcat
with
Liferay
.


1 - Vaadin 6 standard way

Insert all the utility JARs that I need for all projects into Liferay libs (ROOT/WEB-INF/lib), and take a copy of everyone in each project using the
liferay-plugin-package.properties
, like it is for vaadin.jar


2 - customizing Class Loader

Remove the vaadin.jar from Liferay lib and all liferay-plugin-package.properties, taking only one centralized copy into the Tomcat Common Libraries, among with all the utility JARs which must be reachable to all project.
Create a new Class which extends ApplicationPortlet2 and overrides the getCLassLoader method in this way:

 protected ClassLoader getClassLoader() throws ServletException {
        return Thread.currentThread().getContextClassLoader();
    }

Replacing the standard
portlet-class
in the
portlet.xml
files with this new Class

In each way portlets look to work fine, as long I have tested, but which solution do you think could be the best and why?

Thanks in advance for your opinions.

The safest (and most common) way is 1) - use WEB-INF/lib; you’ll note that this is not (specifically) the Vaadin standard way, but the J2EE standard way.

By using WEB-INF/lib, you’ll be able to deploy applications with different versions of jars (which is sometimes necessary). It also makes it very easy to build and deploy web applications (as it possible to create a single web application directory/war file containing everything that can be deployed). This ease of deployment means you can also pick up a standard WAR file and deploy it in Jetty, Tomcat, Websphere, Weblogic, OC4J, Winstome - or any other standard J2EE web application with no changes whatsoever - usually just by placing the WAR file in a directory.

In short - unless you have a concrete reason to do so (disk space on an embedded device?) - I’d strongly suggest using WEB-INF/lib.

Cheers,

Charles.

Thanks Charles. :slight_smile: