Include custom libraries in Liferay

Hi there,

I am trying out Liferay+Vaadin. Have already some experience in developing Vaadin applications, but the issue is now different.

I want to include a project related library in Liferay for a portlet to read database data with an Hibernate based service layer. The point is that while settingup Liferay I had to include the vaadin libraries in the

C:\Users\Xavier\Documents\Liferay\liferay-portal\tomcat-7.0.42\webapps\ROOT\WEB-INF\lib
folder,

whereas in order to include successfully this database service layer library I have to place it in the tomcat/lib folder for its classes to be found.

Can’t understand why, then the classes are referenced inside the same pieces of code (vaadin and the database library classes). Don’t understand. Can anybody explain? I guess I need to update some other configuration files but don’t know which.

If possible would like to maintain the most Liferay friendly setup for portlets to work.

Another requirement is that since I am planning to develop several portlets for the liferay site, I would like any resources included to be shared among all portlets.

Many thanks for your help

Regards,

Carlos Conti.

So first of all, using Hibernate in portlets is a bad idea. Although you may have shared classes in the global class loader, at runtime portlets are separate web applications which each instantiate their own copies of beans, database connection pools, ehcache layers (that don’t talk to each other so they don’t know when the contain a stale entity).

You should really do your service layer using Liferay’s ServiceBuilder tool. This will give you a service jar that you can share w/ your portlets but they use the same service implementation (same db connection pool, same ehcache layer, single copy of beans, etc).

Vaadin jars get deployed to ROOT/WEB-INF/lib when you are using the shared Vaadin environment, a pattern that was first created for V6 in Liferay. You can continue to use the shared V7 environment, but you should use the Vaadin 7 Control Panel to help manage your shared resources (addons, themes, widgetset compilation). I have a number of blog posts on Liferay.com that can help you with the V7CP and shared Vaadin 7 environment.

An alternative implementation is the standalone Vaadin environment. In this env, a Vaadin portlet contains everything and shares no resources with the portal - it has it’s own compiled widgetset, it’s own theme resources, it’s own Vaadin jars, etc. So in this impl there are no shared resources, but your built war artifacts have no dependencies on the portal or each other.