Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
calling a service from another portlet liron bar November 7, 2011 2:22 AM
RE: calling a service from another portlet Tejas Kanani November 7, 2011 3:01 AM
RE: calling a service from another portlet liron bar November 7, 2011 3:15 AM
RE: calling a service from another portlet Tejas Kanani November 7, 2011 3:20 AM
RE: calling a service from another portlet liron bar November 7, 2011 3:31 AM
RE: calling a service from another portlet Tejas Kanani November 7, 2011 3:34 AM
RE: calling a service from another portlet liron bar November 7, 2011 3:39 AM
RE: calling a service from another portlet Tejas Kanani November 7, 2011 3:43 AM
RE: calling a service from another portlet Juan Gonzalez November 7, 2011 6:54 AM
RE: calling a service from another portlet liron bar November 7, 2011 11:58 PM
RE: calling a service from another portlet Tejas Kanani November 8, 2011 3:09 AM
RE: calling a service from another portlet liron bar November 16, 2011 6:53 AM
RE: calling a service from another portlet Jan van der Kaaden November 16, 2011 11:32 PM
RE: calling a service from another portlet liron bar November 17, 2011 8:01 AM
RE: calling a service from another portlet Mathieu Hicauber December 21, 2011 9:16 AM
RE: calling a service from another portlet Juan Gonzalez November 17, 2011 9:42 AM
RE: calling a service from another portlet Tejas Kanani November 7, 2011 3:06 AM
RE: calling a service from another portlet mohammad azaruddin May 22, 2013 2:29 AM
RE: calling a service from another portlet Aritz Galdos November 7, 2011 3:59 AM
RE: calling a service from another portlet Ashish Ranjan November 7, 2011 6:34 AM
liron bar
calling a service from another portlet
November 7, 2011 2:22 AM
Answer

liron bar

Rank: Junior Member

Posts: 29

Join Date: September 27, 2011

Recent Posts

hi,

i created a service in my portlet.
now i want to call the update method of this service from another portlet i created.
but it doesnt work.
it's telling me the method (update) doesnt exits.

what should i do?

thanks,
liron.
Tejas Kanani
RE: calling a service from another portlet
November 7, 2011 3:01 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Hi liron,

As per my understanding, You need to put 1st portlet's jar into 2nd portlet's lib folder in order to access its service.
As we can't access any methods of any portlet outside it except we keep it's jar in tomcat/lib.

Thanks,
Tejas Kanani
Tejas Kanani
RE: calling a service from another portlet
November 7, 2011 3:06 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Also have look at PortletClassInvoker.invoke(boolean newInstance, String portletId, MethodKey methodKey,Object... arguments)

I think you can use this to invoke your service from outside your portlet. But it's not a good approach to use.

Thanks,
Tejas Kanani
liron bar
RE: calling a service from another portlet
November 7, 2011 3:15 AM
Answer

liron bar

Rank: Junior Member

Posts: 29

Join Date: September 27, 2011

Recent Posts

hi,

thanks for the reply.
i already put the service.jar in the lib of the second portlet, and it doesnt work.
the wierd part is that i can do get method but not update
Tejas Kanani
RE: calling a service from another portlet
November 7, 2011 3:20 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Hmmm that's strange.

Not sure, but check your method scope. Is your update method private or what ?

Thanks,
Tejas Kanani
liron bar
RE: calling a service from another portlet
November 7, 2011 3:31 AM
Answer

liron bar

Rank: Junior Member

Posts: 29

Join Date: September 27, 2011

Recent Posts

it's public.
i can see it when i wrote the code, but when i debug and want to ente that method the debugger doesnt recognize the portlet
Tejas Kanani
RE: calling a service from another portlet
November 7, 2011 3:34 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Have you created service using service builder ?
liron bar
RE: calling a service from another portlet
November 7, 2011 3:39 AM
Answer

liron bar

Rank: Junior Member

Posts: 29

Join Date: September 27, 2011

Recent Posts

yes.
a simple service.
Tejas Kanani
RE: calling a service from another portlet
November 7, 2011 3:43 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Not sure whether it will resolve your problem or not.

But you can try creating services again,if it was not properly created.
Just take backup of *Impl.java class and delete all other classes created by Service Builder.
And just re-build service using service builder and replace your *Impl.java with existing and build-service again.
Give it a try, I hope it should resolve your problem.

Thanks,
Tejas Kanani
Aritz Galdos
RE: calling a service from another portlet
November 7, 2011 3:59 AM
Answer

Aritz Galdos

Rank: Expert

Posts: 397

Join Date: May 15, 2007

Recent Posts

Hi Liron:

In order to access the service implemented in one portlet from another, you have to make the service accesible from the second portlet. Which means that you have to MOVE the *-service.jar file into [TOMCAT_HOME]/lib/ext

Stepts to follow:

1-Deploy portlet 1 (The one that implements the service)
2-Stop tomcat
3-MOVE (not copy) *-service.jar to the tomcat´s libs so service will be accesible for all
4-Startup tomcat
5- Deploy dependant portlet

This should do. But take care whenever you redeploy portlet 1

Hope that helps

Regards
Ashish Ranjan
RE: calling a service from another portlet
November 7, 2011 6:34 AM
Answer

Ashish Ranjan

Rank: Junior Member

Posts: 49

Join Date: December 10, 2009

Recent Posts

Hi liron,
You can create the another portlet within the same war file.After that u can access the service of first portlet and no need to put the jar file in lib/ext.

Regards,
Ashish Ranjan
Juan Gonzalez
RE: calling a service from another portlet
November 7, 2011 6:54 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2069

Join Date: October 28, 2008

Recent Posts

I remember there was an error while trying to access other custom portlet services. Theorically, the way it should be done is copying the service jar (only interfaces, models ,etc) in client portlet WAR (not into shared lib).

This error is solved in 6.1, but exists in 6.0.5 and 6.0.6.

If I find the JIRA issue I'll post here.
liron bar
RE: calling a service from another portlet
November 7, 2011 11:58 PM
Answer

liron bar

Rank: Junior Member

Posts: 29

Join Date: September 27, 2011

Recent Posts

hi,

thank you all for your suggestions.

putting the -service.jar in the tomact doesnt worked.

putting the two portlets in the same war is a good suggestion but in my project i'll have a lot of portlets using the services i created in the general portlet, so it will be a little bit ugly.

and i'm using liferay 6.0.5, so i guess i still have the problem...
Tejas Kanani
RE: calling a service from another portlet
November 8, 2011 3:09 AM
Answer
liron bar
RE: calling a service from another portlet
November 16, 2011 6:53 AM
Answer

liron bar

Rank: Junior Member

Posts: 29

Join Date: September 27, 2011

Recent Posts

hi juan,

i upgraded my liferay version to 6.1

but i still cant add or update.

now i get java.lang.IllegalArgumentException: argument type mismatch

do you know something about it?
Jan van der Kaaden
RE: calling a service from another portlet
November 16, 2011 11:32 PM
Answer

Jan van der Kaaden

Rank: New Member

Posts: 20

Join Date: March 20, 2011

Recent Posts

I run into a same kind of problem when i built a web-service (not generated by Liferay) as an non Liferay project and wanted it to write to the Liferay database using the generated orm layers of Liferay.
For me, the way to go was what Aritz described but you have to keep in mind that, like he said, you move the *-service.jar (so be sure it is not any more in your WEB-INF/lib folder) every time you build using the service builder.
To make moving the file easier i added this to my ant build script:

<move todir="${app.server.dir}/lib/ext">
<fileset dir="docroot/WEB-INF/lib">
<include name="*-service.jar" />
</fileset>
</move>

and i simply run this script after building the service.
liron bar
RE: calling a service from another portlet
November 17, 2011 8:01 AM
Answer

liron bar

Rank: Junior Member

Posts: 29

Join Date: September 27, 2011

Recent Posts

it's still doesnt work.

the portlet is recognize the service.
i can do get, create and delete from the service,
but i still cant do add or update.

anyone? idea?

thanks!
Juan Gonzalez
RE: calling a service from another portlet
November 17, 2011 9:42 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2069

Join Date: October 28, 2008

Recent Posts

liron bar:
hi juan,

i upgraded my liferay version to 6.1

but i still cant add or update.

now i get java.lang.IllegalArgumentException: argument type mismatch

do you know something about it?



Better if you attach here error logs and service.xml.

Post here code snippet where you are making the invocation....
Mathieu Hicauber
RE: calling a service from another portlet
December 21, 2011 9:16 AM
Answer

Mathieu Hicauber

Rank: Junior Member

Posts: 79

Join Date: December 22, 2010

Recent Posts

Hi - same problem here : no update or create possible (classloader issue I guess). did you solve it ?

Thank you,

Mathieu.
mohammad azaruddin
RE: calling a service from another portlet
May 22, 2013 2:29 AM
Answer

mohammad azaruddin

Rank: Expert

Posts: 454

Join Date: September 17, 2012

Recent Posts

Hi tejas

If we put service.jar in global directory then we can only retreive the data from database.
So what if we want to add new entry.....?
because EntityImpl() Class is present in docroot\WEB-INF\classes,which doesn't present in service.jar

So i created JAR for docroot\WEB-INF\classes and put in global lib folder. i can able find EntityImpl() class during compile time.but during run time i'm getting exception.Can you please refer this forum post

Warm Regards