Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Satish Bhor
How to avoid Liferay to adding jars in portlet on deployment in liferay?
August 28, 2012 5:31 AM
Answer

Satish Bhor

Rank: New Member

Posts: 17

Join Date: December 20, 2011

Recent Posts

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.
David H Nebinger
RE: How to avoid Liferay to adding jars in portlet on deployment in lifera
August 28, 2012 7:01 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 5766

Join Date: September 1, 2006

Recent Posts

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.
Jaynil A Bagdai
RE: How to avoid Liferay to adding jars in portlet on deployment in lifera
September 2, 2012 11:56 PM
Answer

Jaynil A Bagdai

Rank: Regular Member

Posts: 117

Join Date: March 3, 2012

Recent Posts

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?
David H Nebinger
RE: How to avoid Liferay to adding jars in portlet on deployment in lifera
September 3, 2012 9:02 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 5766

Join Date: September 1, 2006

Recent Posts

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.
Sampsa Sohlman
RE: How to avoid Liferay to adding jars in portlet on deployment in lifera
September 12, 2012 3:58 AM
Answer

Sampsa Sohlman

LIFERAY STAFF

Rank: Regular Member

Posts: 217

Join Date: September 27, 2007

Recent Posts

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

1<context-param>
2      <param-name>portalContextConfigLocation</param-name>
3      <param-value>/WEB-INF/applicationContext.xml</param-value>
4</context-param>


and create /WEB-INF/applicationContext.xml


1<beans .....>
2   
3    <bean id="my.service.MyService" class="my.service.MyServiceImpl"/>
4</beans>


These services are also visible to other web applications and to theme with PortletBeanLocatorUtil:
1PortletBeanLocatorUtil
2                    .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)