Foren

How to avoid Liferay to adding jars in portlet on deployment in liferay?

Satish Bhor, geändert vor 11 Jahren.

How to avoid Liferay to adding jars in portlet on deployment in liferay?

New Member Beiträge: 17 Beitrittsdatum: 21.12.11 Neueste Beiträge
Hi All,
I have created shared lib folder there i have kept all jar files global level and i dont want liferay to add jars to portles WEB-INF/lib folders,Liferay adds some jars on portlet or theme deployment in WEB-INF/lib ,How i can avoid liferay to add jars to portlets and themes.


Thank you...
Satish.
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: How to avoid Liferay to adding jars in portlet on deployment in lifera

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
First of all using global jars is generally a bad practice. It means that all apps must use the same jar versions, and you will sometimes encounter problems trying to upgrade versions (i.e. Liferay uses Lucene, but if you put lucene jars as global jars and try to upgrade lucene yourself, you may have Liferay compatibility issues).

Second of all, class loader is first-come, first-serve with the global jars taking priority. When a global jar is loaded, that one will be used, the local one will be ignored.

So whether the jars are copied or not, it doesn't matter as they would not be used.
thumbnail
Jaynil A Bagdai, geändert vor 11 Jahren.

RE: How to avoid Liferay to adding jars in portlet on deployment in lifera

Regular Member Beiträge: 119 Beitrittsdatum: 03.03.12 Neueste Beiträge
Hi David,

I do have same problem. In my project I am using spring framework for portlet development so i will be needing all spring jars at lib folder of portlet.
Now when deployment done of all portlets, all spring jars being copied in lib folder and due to limitation of resources in server "out of memory" exception comes.

I do have more than 70 portlets in my project. Any idea that if I want to move all these spring jars at global level how can I do that?
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: How to avoid Liferay to adding jars in portlet on deployment in lifera

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
You can move the spring jars to the global lib/ext, but you have to understand the implications of doing this...

The global lib/ext jars will always take precedence over jars in the WEB-INF/lib folder. This means that every web application that you deploy to your tomcat container will be using the same version of Spring across the board. This may or may not be a problem for you depending upon your environment.

You should always use the versions that come with the Liferay bundle. If you try to use a different version, you will have to fully test everything to ensure it is working correctly.

Note that promoting some jars to the global lib/ext directory sometimes will require other jars be promoted. At startup or usage, you may see weird class not found or other classloader-related exceptions. These are typically resolved by promoting the related jars, although I'm not aware of any defined list that would help you handle the promotion.
thumbnail
Sampsa Sohlman, geändert vor 11 Jahren.

RE: How to avoid Liferay to adding jars in portlet on deployment in lifera

Regular Member Beiträge: 230 Beitrittsdatum: 27.09.07 Neueste Beiträge
Hi Jaynil

Jaynil A Bagdai:
I do have more than 70 portlets in my project. Any idea that if I want to move all these spring jars at global level how can I do that?


If you are using only services and (Spring MVC I have not tried) you can use Liferay interal Spring too so your portlet application will come lighter.

Add following to /WEB-INF/web.xml

<context-param>
      <param-name>portalContextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>


and create /WEB-INF/applicationContext.xml


<beans .....>
	
	<bean id="my.service.MyService" class="my.service.MyServiceImpl" />
</beans>


These services are also visible to other web applications and to theme with PortletBeanLocatorUtil:
PortletBeanLocatorUtil
					.locate(servletContextName, "my.service.MyService");


If you want that other applications are able to see your pojos/intefaces then copy those to other jar file and put that under tomcat classloader/<tomcat>/lib (but carefully minimize the depedencies, since you have to those too)