Foros de discusión

How to share java class between to plugin portlets?

thumbnail
meera prince, modificado hace 11 años.

How to share java class between to plugin portlets?

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
HI ALL
I have PortletA have one java class called X.java class.
I have another portlet PortletB so that i want load X.java class in PortletB.

If we use portlal class loader then i need to put jar file in tomacta/lib/ext i don't want do this. without ding all i want load x.java class in PortletB.


Regards,
Meera Prince
thumbnail
Gnaniyar Zubair, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
As both are in different context, you cannot access the API from one to another portlet . But I am not sure whether any possibilities are there.

But, you can achieve If 2 portets are in same WAR.

If you want to have the control for transaction service of another portlet, then you can inject the package thorugh service.xml.
thumbnail
meera prince, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi Gnaniyar Zubair,

Those are two different contexts.
i want solution like following

PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.model.impl.UserImpl")

Ex:
PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.model.impl.UserImpl");

For this class should be available in global class path.



Regards,
Meera Prince
thumbnail
Masroor Khan, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Regular Member Mensajes: 124 Fecha de incorporación: 9/09/08 Mensajes recientes
Hi,

If you want to use like
PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.model.impl.UserImpl");

you need to put your portlet service jar file to tomcat/lib/ext


Regards,

Masroor
thumbnail
meera prince, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi Masroor Khan,
Yes your correct.. but i dont wana do such things. is there any possibility to load portlet class into other portlet.
I have seen like this code
ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");
classLoader. loadClass("your portlet class name with fully qualified name");

but here also service jar should avilable in tomcat/lib/ext


Regards,
Meera Prince
thumbnail
Masroor Khan, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Regular Member Mensajes: 124 Fecha de incorporación: 9/09/08 Mensajes recientes
Hi,

yes service jar should avilable in tomcat/lib/ext

or As Gnaniyar Zubair suggested you need to keep both portlet in same war file.


Regards,

Masroor Khan
thumbnail
meera prince, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
HI thanks Masroor Khan ,
Ya understand the concept i am looking for the another alternative solutions.

Regards,
Meera Prince
thumbnail
Gnaniyar Zubair, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
portal class loader also will find the jar file from global level. emoticon

If you have more dependencies with other portlets, you can create in one WAR file.
thumbnail
meera prince, modificado hace 11 años.

RE: How to share java class between to plugin portlets?

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Thank you Gnaniyar Zubair,

HI please give me solution for this
required-deployment -context property not working in liferay 6.0.6.

https://www.liferay.com/community/forums/-/message_boards/message/13505223

Regards,
Meera Prince
Sreeja Surendranath, modificado hace 9 años.

RE: How to share java class between to plugin portlets?

New Member Mensajes: 15 Fecha de incorporación: 9/01/14 Mensajes recientes
Hi,

In this regard, could you please clarify this query as well?

Are there chances for any conflicts if two wars are deployed in the same page and have a class with same name and package structures in both of them?
eg: portlet A has com.portlet.util.Utility
portlet B also has com.portlet.util.Utility
and both are deployed in the same page. But both has different methods.

The context is that I got a method not found exception in portlet A when it actually has the method in Utility. But the Utility class in B does not have that method.

Please help.