Deploying vaadin portlets - shared jars problem

Hello all,

I am trying to deploy 5 vaadin portlets and all use the same jars. I wanted to share these jars between all portlets without making copies of them on each portlet. I tried putting all of them, including vaadin.jar, on the lib, lib/ext, I configured common.folder with a new folder or shared.folder on, I also tried leaving vaadin.jar on the WEB-INF/lib and the rest on one of the examples below and I always got an error on the hot deploy saying that it cannot find the com.vaadin.terminal.gwt.server.PortletApplicationContext2.PortletListener class… The only way it works is putting all jars on each WEB-INF/lib folder of each portlet… Anyone ever tried to centralize all these jars successfully? If so could you help me?



It is happening because Vaadin uses its own ClassLoader.

I would like to share a single Vaadin jar among many projects. Is it really needed to use a custom ClassLoader?



Vaadin does not use custom classloaders, but the server you are using does depending on from where classes are loaded.

If e.g. using Liferay on Tomcat, if I remember correctly, separate classloaders are used for 1) JARs on Tomcat classpath 2) JARs from Liferay shared WEB-INF/lib and referenced via and 3) JARs in the portlet itself. Nevertheless, Liferay also copies the referenced JARs from 2 to the deployed portlet directory at deployment time.

To share a single Vaadin JAR, do not deploy multiple copies of it (i.e. do not deploy the JAR in the portlet/servlet WAR) but only use a suitably shared one on the portal/servlet container. How to deploy and reference the shared one depends on the server you are using.

Hi, Henri!

Thanks for your reply.

Maybe you can help me on this subject, and help others who are also trying to share Vaadin jar.

Looking at tomcat docs, it says we should put shared libs on the ‘lib’ folder in the tomcat installation directory.

So i did put vaandin jar, jdbc driver jar and a connection polling jar there.

When i try to run my application, it throws a ClassNotFound exception, regarding a Vaadin class.

If i put just the Vaadin jar inside WEB-INF/lib folder in the war file, then it runs ok (it loads the jdbc and connection pooling from tomcat lib folder).

Btw, i´m not developing a portlet nor using liferay, so i just want to share the vaadin jar with all my applications deployed in the same Tomcat server.



Hi, i have found a solution for this problem.

I subclassed ApplicationServlet class and changed web.xml to use this class instead of original ApplicationServlet

package br;

import javax.servlet.ServletException;

import com.vaadin.terminal.gwt.server.ApplicationServlet;

public class ApplicationServletSubclass extends ApplicationServlet {

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