Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Satish Bhor
How to avoid Liferay to adding jars in portlet on deployment in liferay?
28 agosto 2012 5.31
Risposta

Satish Bhor

Punteggio: New Member

Messaggi: 17

Data di Iscrizione: 20 dicembre 2011

Messaggi recenti

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
28 agosto 2012 7.01
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 7080

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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
2 settembre 2012 23.56
Risposta

Jaynil A Bagdai

Punteggio: Regular Member

Messaggi: 120

Data di Iscrizione: 3 marzo 2012

Messaggi recenti

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
3 settembre 2012 9.02
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 7080

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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
12 settembre 2012 3.58
Risposta

Sampsa Sohlman

LIFERAY STAFF

Punteggio: Regular Member

Messaggi: 218

Data di Iscrizione: 27 settembre 2007

Messaggi recenti

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)