Foros de discusión

How to use one plugins portlet in another

thumbnail
Guru Murthy, modificado hace 11 años.

How to use one plugins portlet in another

Regular Member Mensajes: 208 Fecha de incorporación: 12/08/11 Mensajes recientes
Hi Everybody ,
I am using Liferay 6.0.6 with MySQL and Tomcat 6.0.29 .
I have producer plugins portlet and I want to make it available for all consumer portlet . How can I ?
Actually I kept Producer plugins portlet service.jar file into server/lib folder so I am able to use it in all consumer portlet but i don't want like this . I want to provide it by just adding one property in "liferay-plugin-package.properties " in all consumer portlet just like how we are adding the dependency jar files to plugins portlet .


portal.dependency.jars=\antlr.jar,\commons-beanutils.jar,\commons-collections.jar,\commons-digester.jar,\commons-fileupload.jar,\commons-io.jar,\ commons-lang.jar,\commons-validator.jar,\jcommon.jar,\jfreechart.jar,\oro.jar,\portals-bridges.jar,\struts.jar,\jstl.jar,\jstl-impl.jar,\portal-service.jar

portal.dependency.tlds=struts-bean.tld,struts-bean-el.tld,struts-html.tld,struts-html-el.tld,struts-logic.tld,struts-logic-el.tld,struts-nested.tld,struts-tiles.tld,struts-tiles-el.tld,liferay-ui.tld,c-rt.tld


Just like above properties , Is there any other properties which is useful to use one plugins portlet in another ?
thumbnail
David H Nebinger, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Just use the required deployment context in the consumer portlets. Add the producer as the required context. Service jar will be shared automatically.
thumbnail
Guru Murthy, modificado hace 11 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 208 Fecha de incorporación: 12/08/11 Mensajes recientes
Hi David ,

I made producer portlet and i deployed it also , after that i made one consumer portlet and i wrote required-deployment-context property in consumer liferay-plugin-package.properties file , see it below .

required-deployment-contexts = producer-portlet


But still i am unable to use producer-portlet service layer util classes . Let me know if i done any wrong step in this process .

Did u try it ? if yes then please forward skeleton of liferay-plugin-package.properties file also .

Thanks ,
G.Gurumurthy .
thumbnail
Muhammed Shakir AK Misarwala, modificado hace 11 años.

RE: How to use one plugins portlet in another

Junior Member Mensajes: 36 Fecha de incorporación: 26/02/09 Mensajes recientes
Hi David,

Have you tried this your self ?
thumbnail
Muhammed Shakir AK Misarwala, modificado hace 11 años.

RE: How to use one plugins portlet in another

Junior Member Mensajes: 36 Fecha de incorporación: 26/02/09 Mensajes recientes
David H Nebinger:
Just use the required deployment context in the consumer portlets. Add the producer as the required context. Service jar will be shared automatically.


Have you tried this yourself David ?
thumbnail
David H Nebinger, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Yes, we use this method exclusively in our production systems as it saves having to move jars to lib/ext and the inevitable stop/start of the application container (basically we can hot deploy these guys and it just works).

We have one portlet project that has the only service builder-managed service layer. We wanted to keep all of our extraneous data access stuff in a single project to keep the architecture simple.

All of our other separate portlet projects need the data services provided by this project, so in the liferay-plugin-package.properties file, the service providing plugin is added as a required deployment context.

Most of the magic is enforced by the IDE, so you must be using the IDE also (I don't know if there are plans to include the magic into the ant build process, but it would be nice if they did emoticon ).

Anyways the dependent projects will get updated service jars (prior to build/deploy time) and they can access the service layer provided by the service providing project.

The Liferay runtime will not complete the initialization of a project with an unsatisfied required deployment context, so the dependent projects sit in a queue at startup until the required deployment context entities have been properly loaded and initialized. So they will wait until the service providing portlet is loaded, then they will be loaded afterwards. Saves on all of those typical 'BeanLocator' exceptions, too.
Pietro Santoro, modificado hace 11 años.

RE: How to use one plugins portlet in another

New Member Mensajes: 16 Fecha de incorporación: 4/05/08 Mensajes recientes
Hi David,
this works with LR 5.1.2? Or only with LR 6.x?

Thanks

Pietro

David H Nebinger:
Yes, we use this method exclusively in our production systems as it saves having to move jars to lib/ext and the inevitable stop/start of the application container (basically we can hot deploy these guys and it just works).

We have one portlet project that has the only service builder-managed service layer. We wanted to keep all of our extraneous data access stuff in a single project to keep the architecture simple.

All of our other separate portlet projects need the data services provided by this project, so in the liferay-plugin-package.properties file, the service providing plugin is added as a required deployment context.

Most of the magic is enforced by the IDE, so you must be using the IDE also (I don't know if there are plans to include the magic into the ant build process, but it would be nice if they did emoticon ).

Anyways the dependent projects will get updated service jars (prior to build/deploy time) and they can access the service layer provided by the service providing project.

The Liferay runtime will not complete the initialization of a project with an unsatisfied required deployment context, so the dependent projects sit in a queue at startup until the required deployment context entities have been properly loaded and initialized. So they will wait until the service providing portlet is loaded, then they will be loaded afterwards. Saves on all of those typical 'BeanLocator' exceptions, too.
thumbnail
David H Nebinger, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
I don't believe so...

Even though the magic is performed by the IDE (for the jar file moving), I don't think 5.x used the liferay-plugin-package.properties file where you define the required deployment context...
thumbnail
Rishi Dev Gupta, modificado hace 11 años.

RE: How to use one plugins portlet in another

Expert Mensajes: 255 Fecha de incorporación: 23/11/08 Mensajes recientes
David H Nebinger:
I don't believe so...

Even though the magic is performed by the IDE (for the jar file moving), I don't think 5.x used the liferay-plugin-package.properties file where you define the required deployment context...



IDE can assist in development and can allow defining various properties in easily readable form, but i don't think that IDE will just move the service jar from one portlet to another. Because all the dependency jars are copied during the process of deployment of portlet.

Earlier i have done this by moving the service jars to tomcat lib and then used services in other portlets.

Still I will give a try to this.
thumbnail
Rishi Dev Gupta, modificado hace 11 años.

RE: How to use one plugins portlet in another

Expert Mensajes: 255 Fecha de incorporación: 23/11/08 Mensajes recientes
Bingo this works...
It is done by Liferay's deployment API and not by IDE. Thus when hot portlet deployment is done, it looks for the defined dependency context's and copies the service jar to the portlet and then completes the deployment.

One more thing, if i have 2 portlets A and B. B is dependent on A.
I have deployed A and then B, thus As B have dependency on A.
Now after successful deployment of B, it will have service jar of A copied locally.

Suppose in future i just update the service for A and redeploy it, will this modified service jar of A be synched with existing portlet B also or will both A and B have 2 different version jars and i have to redeploy B later?
thumbnail
David H Nebinger, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
I don't know that this is accurate...

Start a project C and declare that it is a dependency on A in liferay-plugin-package.properties, but don't build or deploy the project. If you check C's WEB-INF/lib directory, you'll see A's service jar in there. This allows code added to C in the IDE to reference the service classes and not display compile/link errors.

This indicates that it is a function of the IDE. At deploy time the service jar is already there so it doesn't need to get pulled in during deployment.

As far as hot deploy goes, under 6.0 the hot deploy process is not pulling in the service jar at deploy time. 6.1 might do it, but I don't know that it does.

Since it is a function of the IDE and not the deploy process, A's service jar does not get propagated when you deploy an update for A. You must rebuild and redeploy the depending portlets for the updated service jar to get deployed.
thumbnail
meera prince, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi David H Nebinger,
I have used required deployment context for one my portlet but this is not working. i am using liferay 6.0.6 .
When i used this property the compilation errors was resolved in the IDE. once deploy the portlets when run then i got following error. one more thing after deploy when i looked into portlet in tomacat webapp directory. the sharable service jar not availbale in WEB-INF/lib of required portlet. i want clear one thing sharable service jar should available in portlet WEB_INF/lib or not.

The following is exception

java.lang.NullPointerException
at com.vidyayug.global.service.RoleLandingPageLocalServiceClp.<init>(RoleLandingPageLocalServiceClp.java:474)
at com.vidyayug.global.service.RoleLandingPageLocalServiceUtil.getService(RoleLandingPageLocalServiceUtil.java:262)
at com.vidyayug.global.service.RoleLandingPageLocalServiceUtil.getRoleLandingPage(RoleLandingPageLocalServiceUtil.java:170)

Regards,
Meera Prince
Siby Mathew, modificado hace 11 años.

RE: How to use one plugins portlet in another

Expert Mensajes: 268 Fecha de incorporación: 4/03/11 Mensajes recientes
Hi Meera,
If you keep it in required-deployment-contexts, the dependent service jar WILL BE copied in the deployed war.

Thanks,
Siby
thumbnail
meera prince, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
HI thank you Siby Mathew,

That was not happens in liferay6.0.6.
when i looked into tomcat deployed portlet lib i could not find the service jar.
i manually copy in tomcat webapp portlet context lib directory. then i got null pointer exception.
Please go through the my link and see my post there.
Regards
Meera Prince
http://www.liferaysavvy.com/
thumbnail
David H Nebinger, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
The service jar is only copied if you are using the Liferay IDE. If you are not using the IDE, or you are relying strictly on ant, you must copy the service jar manually.
thumbnail
meera prince, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi David H Nebinger,
I observed that LiferayIDE not doing that actions. Because i went through the portlet lib which is in tomcat server.

i am using LiferayIDE1.4 and Liferay60.6
Here one question i have. If i use service jar in different portlets by using required-deployment-context property late if i updated or add some new methods in service jar what will happend?
Weather all contexts which uses service jar updated automatically or we need to take care each and every portlet


Regards,
Meera Prince
http://www.liferaysavvy.com/
Siby Mathew, modificado hace 11 años.

RE: How to use one plugins portlet in another

Expert Mensajes: 268 Fecha de incorporación: 4/03/11 Mensajes recientes
Hi Meera,
Which post do you mean ?
You mean you tried to copy the file manually to lib of webapps/yourportlet and still got a NPE ?
In case you are manually entering the dependency, please make sure the text is same as this (with hyphens) :
required-deployment-contexts=

Thanks,
Siby
thumbnail
meera prince, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi Siby Mathew the following post i said.

I have used required deployment context for one my portlet but this is not working. i am using liferay 6.0.6 .
When i used this property the compilation errors was resolved in the IDE. once deploy the portlets when run then i got following error. one more thing after deploy when i looked into portlet in tomacat webapp directory. the sharable service jar not availbale in WEB-INF/lib of required portlet. i want clear one thing sharable service jar should available in portlet WEB_INF/lib or not.

The following is exception

java.lang.NullPointerException
at com.vidyayug.global.service.RoleLandingPageLocalServiceClp.<init>(RoleLandingPageLocalServiceClp.java:474)
at com.vidyayug.global.service.RoleLandingPageLocalServiceUtil.getService(RoleLandingPageLocalServiceUtil.java:262)
at com.vidyayug.global.service.RoleLandingPageLocalServiceUtil.getRoleLandingPage(RoleLandingPageLocalServiceUtil.java:170)

Regards,
Meera Prince
Siby Mathew, modificado hace 11 años.

RE: How to use one plugins portlet in another

Expert Mensajes: 268 Fecha de incorporación: 4/03/11 Mensajes recientes
Hi Meera,
The expected behaviour is :
- The shared service jar should be present in the deployed war.

- Consider Portlet B is dependent on PortletA.
- portletA-service.jar should be present inside Portlet-B.war during deployment.

I assume PortletA has been already deployed by you. Am I right ?
If not, PortletB will wait in queue till PortletA is deployed. Can you make sure that its not in queue ?

Thanks,
Siby
thumbnail
meera prince, modificado hace 11 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi Siby Mathew
first i deployed PortletA and then i have used required-deployment-context=PortletA
in PortletB and then i deployed portletB.

After deployment i got class not found exception. then i looked into deployed war of portletB i could not found PortletA-service.jar in lib directory of PortletB war in tomcat server.
then i just manually copy the portletA-service.jar to lib of PortletB war which in tomcat server.
then i got following exception

java.lang.NullPointerException
at com.vidyayug.global.service.RoleLandingPageLocalServiceClp.<init>(RoleLandingPageLocalServiceClp.java:474)
at com.vidyayug.global.service.RoleLandingPageLocalServiceUtil.getService(RoleLandingPageLocalServiceUtil.java:262)
at com.vidyayug.global.service.RoleLandingPageLocalServiceUtil.getRoleLandingPage(RoleLandingPageLocalServiceUtil.java:170)



Regards,
Meera Prince
http://www.liferaysavvy.com/
thumbnail
Kalai arasan, modificado hace 10 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
I used required deployment context and i can able to access portlet A's service from portlet B. But i build another one service named .VisitorAppointmentcontacts in Portlet B's service builder, follwing exception occurs
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.test.service.VisitorAppointmentcontactsLocalService' is defined
Please tell me how to solve this problem?
thumbnail
Kalai arasan, modificado hace 10 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
Hi! I used the finder method in Portlet A like as
public List<Applicationfulldetails> findByApplicationno(final String Applicationno) throws SystemException {
return applicationfulldetailsPersistence.findByApplicationno(Applicationno);
}
after build the service that is working fine for both portlets A and B. But when i closed the eclipse and started again that shows the following exception,
"Only a type can be imported. com.test.service.ApplicationfulldetailsLocalServiceUtil resolves to a package" Please tell me where is the mistake occured?
thumbnail
Kalai arasan, modificado hace 9 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
Hi!
I access the project A from Project B by required deployment context.But i want to forward the jsp from project A to project B!
If you know how redirect the jsp page from Project A to Project B, please tell me!
thumbnail
Jitendra Rajput, modificado hace 9 años.

RE: How to use one plugins portlet in another

Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
You can user PortletFactoryUtil to create a URL.

PortletURL portletURL = PortletURLFactoryUtil.create(httpRequest ,portletId, plid ,PortletRequest.RENDER_PHASE);
thumbnail
Kalai arasan, modificado hace 9 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
Thanks Mr.Jitendra Rajput for your valuable reply!
thumbnail
Kalai arasan, modificado hace 10 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
Hi!
I access the project A from Project B by required deployment context. but i can't use finder method for access the tables from project B while the table is in Project A!
If you have solution for this problem reply me hoe to use finder method for access Project A from Project B.
thumbnail
David H Nebinger, modificado hace 10 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Finders are not exposed in the service tier. Go into your XxxLocalServiceImpl class and add a method to expose what you're going for (i.e. create a pass through method in Impl that invokes the method in the finder).

Rebuild services and you'll be good to go.
thumbnail
Kalai arasan, modificado hace 10 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
Hi!
I build the service for finder method In, ApplicationfulldetailsLocalServiceImpl as
public java.util.List<com.test.model.Applicationfulldetails> findByApplicationno(String Applicationno)
throws com.liferay.portal.kernel.exception.SystemException {
return ApplicationfulldetailsUtil.findByApplicationno(Applicationno);
}

After deployment context, it works for Project A. Then the entity can be accessible by Project B. But i can't use the finder for Project B, while it works in Project A.?
thumbnail
David H Nebinger, modificado hace 10 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
findByApplicationno() implementation should use the custom finder, not call the Util class...
thumbnail
Kalai arasan, modificado hace 10 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
Ok i understand. But how can i access the util class?
thumbnail
David H Nebinger, modificado hace 10 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Okay, you have two different things here, a service provider and a service consumer.

The service provider has the service.xml file and all of the XxxLocalServiceImpl classes. In here you'd define a method, findByMyCustomFinder() that takes appropriate arguments and returns the list. Since it is an implementation class, it has full access to the persistence layer, the custom finders, and all of the other service builder goodies. And since these are the implementation classes, they should never be using the XxxLocalServiceUtil classes because they are only for consumers. Whatever you want to expose to the consumer, you must put it in XxxLocalServiceImpl as public methods.

The service consumer can only use the XxxLocalServiceUtil classes and the corresponding model interfaces. It has no access to the custom finders or persistence layer or anything. Whatever you want to expose for the consumer to use, they can only get to it through the XxxLocalServiceUtil classes. The service consumer will add an entry in liferay-plugin-package.properties file for a required deployment context, the entry will be the service provider. The Liferay IDE will automagically copy the service jar into your project so the XxxLocalServiceUtil classes are available.
thumbnail
Kalai arasan, modificado hace 10 años.

RE: How to use one plugins portlet in another

Regular Member Mensajes: 127 Fecha de incorporación: 2/01/13 Mensajes recientes
Hi!
when i first start the server both projects will work fine. But when deploy the projects again there is an exception named nosuchBeanDefinitionException will occurs in the second project, how do i resolve that?
thumbnail
meera prince, modificado hace 9 años.

RE: How to use one plugins portlet in another

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi
when we work with sharing service layer we need to have more attention.
When we update portlet services then we need to remove old jar file in lib/ext and replace with new one..

some times service might not updates such scenarios we may get these problems.. so need to clean and redeploy at the same time we need to make sure service jar file should be updated one in global lib i.e. lib/ext

when we place jar file in global lib then server should be stop.

Have look into following post it give some information ...

http://www.liferaysavvy.com/2013/12/sharing-liferay-service-layer-between.html

Regards,
Meera Prince