掲示板

Adding JARS to WEB-INF/lib of Liferay-Portlet

thumbnail
13年前 に Andew Jardine によって更新されました。

Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi,

I'm seeing something that looks odd to me, but I am new to Liferay so this might be an easy answer.

I am working with Liferay 6 (EE actually) and Tomcat 6. I'm using Eclipse Helios and have installed the SDK. I created my Liferay-Portlet project, made some mickey mouse changes to see it deployed and working, everything is good.

Now I am trying to do the real meat. I've move my code over that uses the OpenSAML framework. I add the external jar references to the project and everything is working. Next I added the dependencies to my liferay-plugin-package.properties file such that it shows ...


portal-dependency-jars=\
bcprov-ext-jdk15-1.40.jar,\
commons-codec-1.3.jar,\
commons-collections-3.1.jar,\
commons-httpclient-3.1.jar,\
commons-lang-2.1.jar,\
jargs-1.0.jar,\
jcip-annotations-1.0.jar,\
jcl-over-slf4j-1.5.5.jar,\
joda-time-1.5.2.jar,\
log4j-over-slf4j-1.5.5.jar,\
not-yet-commons-ssl-0.3.9.jar,\
oneid.jar,\
opensaml-2.2.3.jar,\
openws-1.2.2.jar,\
slf4j-api-1.5.6.jar,\
slf4j-jdk14-1.5.6.jar,\
slf4j-nop-1.5.6.jar,\
velocity-1.5.jar,\
xmlsec-1.4.2.jar,\
xmltooling-1.2.0.jar

The strange thing here, and I don't know if it is relevant or not, but I can see this in the text properties view, but on the tab that shows a visual representation, there is nothing listed. I tried adding them one at a time, several, and in bulk -- none worked. Since the entries are in the .properties file, I figured it didn't matter.

When I run the compile action on the ant script, only a few libraries get moved into the WEB-INF/lib folder for the portlet project. The libraries are those required by struts and tiles and none of my OpenSAML dependencies are listed. As a result, when I deploy, I get a pile of class not found exceptions.

I know I can put them in either the Portal WEB-INF/lib or even the app server, but really, I want a cleaner answer here -- make them only available to the portlet that needs it.

Any ideas?

A.
thumbnail
13年前 に Sandeep Nair によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
Hi,

Portal-dependency-jar property is to be used if you think there are some jars that Liferay is already using and you dont want to duplicate them in your portlet lib directory.

For example in the portals ROOT/WEB-INF/lib directory axis.jar is already there, so you dont want to add another axis.jar in your portlet's lib directory.

In that case u would specify the same in portal-dependency-jar so that during deployment it would copy the jars mentioned in portal-dependency-jar from Portals ROOT/WEB-INF/lib to your portlets WEB-INF/lib directory.

But in your case you have added some jars that are not there in portal's ROOT/WEB-INF/lib directory so you get those errors.

Those jars have to be moved to your portlet's WEB-INF/lib directory

Regards,
Sandeep
thumbnail
13年前 に Andew Jardine によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi Sandeep,

I realized that pretty early this morning actually when I saw that the others that were automatically included were in the ROOT/WEB-INF/lib directory.

That still leaves the question though. How do I have libraries that I have added in my eclipse plugin project deployed with the portlet so that they are available only to the portlet itself?

A.
thumbnail
13年前 に Sandeep Nair によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
Hi,

In the custom portlet that you created there is a lib directory
Assuming you have a custom portlet named "xyz-portlet" the path in your plugins sdk is
xyz-portlet\docroot\WEB-INF\lib

Place all your jars here.

Regards,
Sandeep
thumbnail
13年前 に Andew Jardine によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi Sandeep,

That part I am clear on, but what I was wondering (I probably didn't explain myself properly) was if there is a way in my eclipse project to add the libraries (external jars) and then have the ANT script deploy the libraries with the portlet. Basically, I want to be able to create a fully encapsulated WAR from the IDE using the ANT script that I can deploy to any server without having to then go and inject the libraries manually.

Incidentally, I tried adding them after the fact but it seems you have to do it after each deploy because the deploy task removes the existing application and redeploys.

A.
thumbnail
13年前 に Andew Jardine によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi Sandeep,

I read your post again and realized what you were saying... to copy them into the $PLUGIN_SDK\portlets\${portlet.name}\docroot\WEB-INF\lib, rather than in the WEB-INF\lib of the deployed portlet.

Once I do that I see them appear in eclipse. I think I have had this issue with Eclipse before... it allows you to specify libraries as dependencies, but provides no mechanism to bundle them as part of the JAR/WAR/.

One thing though. For some reason, during the clean process, not all of my libraries are maintained. For example, Lets say I have 16 jars. I've noticed that sometimes it'll selectively choose only a handful (say 7) to keep... whcih can cause my code to break. Have you see this before?
thumbnail
13年前 に Binh Thanh Le によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

New Member 投稿: 14 参加年月日: 10/08/01 最新の投稿
Andew Jardine:
Hi Sandeep,

I read your post again and realized what you were saying... to copy them into the $PLUGIN_SDK\portlets\${portlet.name}\docroot\WEB-INF\lib, rather than in the WEB-INF\lib of the deployed portlet.

Once I do that I see them appear in eclipse. I think I have had this issue with Eclipse before... it allows you to specify libraries as dependencies, but provides no mechanism to bundle them as part of the JAR/WAR/.

One thing though. For some reason, during the clean process, not all of my libraries are maintained. For example, Lets say I have 16 jars. I've noticed that sometimes it'll selectively choose only a handful (say 7) to keep... whcih can cause my code to break. Have you see this before?


CHeck your WEB-INF/liferay-plugin-package.properties
You ll see something like

name=Portlet name
module-group-id=liferay portlet
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=LGPL

portal-dependency-jars=\
    jstl-api.jar,\
    jstl-impl.jar

portal-dependency-tlds=\
    c.tld


add them to your portal-dependency-jars
thumbnail
13年前 に Andew Jardine によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Binh Thanh Le:
Andew Jardine:
Hi Sandeep,

I read your post again and realized what you were saying... to copy them into the $PLUGIN_SDK\portlets\${portlet.name}\docroot\WEB-INF\lib, rather than in the WEB-INF\lib of the deployed portlet.

Once I do that I see them appear in eclipse. I think I have had this issue with Eclipse before... it allows you to specify libraries as dependencies, but provides no mechanism to bundle them as part of the JAR/WAR/.

One thing though. For some reason, during the clean process, not all of my libraries are maintained. For example, Lets say I have 16 jars. I've noticed that sometimes it'll selectively choose only a handful (say 7) to keep... whcih can cause my code to break. Have you see this before?


CHeck your WEB-INF/liferay-plugin-package.properties
You ll see something like

name=Portlet name
module-group-id=liferay portlet
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=LGPL

portal-dependency-jars=\
    jstl-api.jar,\
    jstl-impl.jar

portal-dependency-tlds=\
    c.tld


add them to your portal-dependency-jars


Hi Binh,

Thanks for the suggestion, but I don't think that will solve my problem. What I understand is that the entries you make in that properties files will pull in libraries that are found in the Portal WEB-INF/lib. I'm trying to avoid putting them in there in the first place since, really, the portal doesn't need them, just the portlet I have created does.

Does anyone else have any suggestions?
thumbnail
13年前 に Sandeep Nair によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
Hi,

Check out my portlet which i have attached. Unzip the same and see the structure. See the lib directory inside my portlet and see the liferay-plugin-package.properties.

The jars inside lib are the external jars and the those mentioned in the liferay-plugin-package.properties are the ones already available.


Regards,
Sandeep.
7年前 に shahsikant shinde によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

New Member 投稿: 1 参加年月日: 16/12/08 最新の投稿
Sandeep Nair:
Hi,

Check out my portlet which i have attached. Unzip the same and see the structure. See the lib directory inside my portlet and see the liferay-plugin-package.properties.

The jars inside lib are the external jars and the those mentioned in the liferay-plugin-package.properties are the ones already available.


Regards,
Sandeep.




Hi,

I want to use portletA-service.jar in a portletA. I am using maven to build the portlet. Please confirm if I can mention
portletA-service.jar as a dependency in POM file of portletA?
Or do I need to place portletA-service.jar inside /ROOT/WEB-INF/lib OR tomat/lib/ext?

Regards,
Shashikant
thumbnail
13年前 に Binh Thanh Le によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

New Member 投稿: 14 参加年月日: 10/08/01 最新の投稿
Andew Jardine:

Hi Binh,

Thanks for the suggestion, but I don't think that will solve my problem. What I understand is that the entries you make in that properties files will pull in libraries that are found in the Portal WEB-INF/lib. I'm trying to avoid putting them in there in the first place since, really, the portal doesn't need them, just the portlet I have created does.

Does anyone else have any suggestions?


No, this is to copy what is in WEB-INF/lib of the portal into your Portlet's LIB folder.

That s exactly what you need.
thumbnail
13年前 に Andew Jardine によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Actually it's not. As I said earlier, I am trying to add JARs to my portlet that are NOT part of the portal and NOT part of the server. The idea here is that the OpenSAML framework that I am using as part of the portlet implementation is not required by either the portal or the server (container), so there is no need to place them in the CATALINA_HOME/lib or the ROOT/WEB-INF/lib.

The example provided by Sandeep is what I am trying to do, but the ANT process is not picking moving all my files from the plugin project folder to the final destination. In fact, it is even going as far as to omit putting them back in the /lib folder after the build is run.

The only way I found around this was to take my set of libraries and create a FAT jar. I placed the FAT jar into the plugins/portlets/[my portlet]/docroot/WEB-INF/lib folder and everything is working now. Strange that it doesn't work the other way though.

At any rate, problem solved for now.

Thanks guys.

A.
13年前 に Jens Göring によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

New Member 投稿: 22 参加年月日: 10/11/18 最新の投稿
Sounds like a problem I had in a similar way when trying to add log4j.jar.

The liferay ant build process deletes some JARs from your WEB-INF/lib folder because it assumes it copied them there itself. The JARs are defined in build.properties:

required.portal.jars=commons-logging.jar,log4j.jar,util-bridges.jar,util-java.jar,util-taglib.jar

The delete command is in the clean-portal-dependencies target of the build-common-plugin.xml file.

I ended up renaming log4j.jar to something different so Liferay won't delete my file.
thumbnail
13年前 に Andew Jardine によって更新されました。

RE: Adding JARS to WEB-INF/lib of Liferay-Portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi Jens,

FAT jar is the way to go for a cleaner project structure anyway (if you ask me). Check it out: http://fjep.sourceforge.net/#inst