Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share jar within multiple portlets?

I'm using several jars in my portlets, for instance c3p0. Now I want to avoid to put the jars in every of my portlets lib folders. How can I share one jar file within multiple portlets? And how should I integrate them in the Eclipse IDE? Add an external jar or put them in one dedicated project and include them from there?

like image 644
strauberry Avatar asked Sep 10 '12 10:09

strauberry


2 Answers

Another solution would be to put them under ../liferay-portal-<version>/tomcat-<version>/webapps/ROOT/WEB-INF/lib

If you place them here you can add the JAR as a dependency for your portlet in the portlets liferay-plugin-package.properties (if you're using Liferay Developer Studio or Liferay IDE then there's a nice GUI for this).

Then on deployment Liferay will copy the required JARS from ROOT/WEB-INF/lib to your portlets WEB-INF/lib

This I believe is the Liferay support mechanism for doing it, and doesn't require a restart because the JARs are copied to the portlets classpath on deployment.

like image 185
Jonny Avatar answered Sep 30 '22 11:09

Jonny


One way I can think off is to put all of them in the global path.

For e.g. in Tomcat you could place them at ../liferay-portal-<version>/tomcat-<version>/lib/ext and then when you configure the server-runtime library in eclipse you will have these jars in your build-path.

This link may also help you decide, but it speaks for *-service.jar but I am not sure it would work other jars in any one portlet.

like image 40
Prakash K Avatar answered Sep 30 '22 10:09

Prakash K