Samstag, 11. Juli 2009

How to access portal-impl.jar and another liferay jars?

The Liferay distribution includes many jars that you want perhaps use in your own application. For example you may want to add new users to liferay from your own portlet and then this portlet have to use portal-impl.jar.
I use Liferay with tomcat and the specific jar can be found in TOMCAT_ROOT/webapps/ROOT/WEB-INF/lib.
So you need to take this jar to compile your portlet. But you are not allowed to add this to your war, because it is not allowed that the same jar - in this case portal-impl.jar - is in your war and in TOMCAT_ROOT/webapps/ROOT/WEB-INF/lib.
But how can your application access these jars?
You have to add to your WEB-INF folder the file
liferay-plugin-package.properties.
There you specify the jars that your application should use out of the TOMCAT_ROOT/webapps/ROOT/WEB-INF/lib folder.
In the key portal-dependency-jars you define the jars should be used.

Example:

name=NeededJarsTest
module-group-id=liferay
module-incremental-version=1
tags=sample
short-description=Demonstration how to access jars
change-log=
page-url=http://g-itblog.blogspot.com
author=Gastons-IT-Blog
licenses=LGPL

portal-dependency-jars=\
commons-beanutils.jar,\
commons-collections.jar,\
commons-digester.jar,\
commons-fileupload.jar,\
commons-lang.jar,\
commons-validator.jar,\
oro.jar,\
portal-impl.jar

speed-filters-enabled=false

Keine Kommentare: