Foros de discusión

Problem calling PortalClassInvoker.invoke with arguments

German Tugores, modificado hace 12 años.

Problem calling PortalClassInvoker.invoke with arguments

Junior Member Mensajes: 33 Fecha de incorporación: 1/03/12 Mensajes recientes
Hi,

I'm developing a portlet with JSF + Icefaces. I need to access some methods from the AnnouncementsEntryLocalServiceUtil class, so I'm using
PortalClassInvoker.invoke for that.

When calling a method with no arguments it works just fine. The problem is when calling a method with arguments.

For example if I call: PortalClassInvoker.invoke("com.liferay.portlet.announcements.service.AnnouncementsEntryLocalServiceUtil","getAnnouncementsEntriesCount");

It brings the counter for AnnouncementEntry table without problems, but If I call:

PortalClassInvoker.invoke("com.liferay.portlet.announcements.service.AnnouncementsEntryLocalServiceUtil","getAnnouncementsEntries", new Object[] {0, 2}, false));

the console doesn't crash but it pops up an error "Server Internal Error" that prompts me to reload the page (an Icefaces message). I see it's deprecated to call the invoke method in this way, I've also tried a different way to call it with MethodKey but with the same bad result.

MethodKey key = new MethodKey("com.liferay.portlet.announcements.service.AnnouncementsEntryLocalServiceUtil", "getAnnouncementsEntries", int.class, int.class);
PortalClassInvoker.invoke(false, key, new Object[] {0, 2});

There has to be an error I'm introducing in the code when calling invoke with arguments, but I don't realize what exactly, any ideas?

Thanks in advance,
Germán
thumbnail
David H Nebinger, modificado hace 12 años.

RE: Problem calling PortalClassInvoker.invoke with arguments

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
You do not have to use PortalClassInvoker to invoke a *LocalServiceUtil class and/or method.

Just call it natively and you're fine.
German Tugores, modificado hace 12 años.

RE: Problem calling PortalClassInvoker.invoke with arguments

Junior Member Mensajes: 33 Fecha de incorporación: 1/03/12 Mensajes recientes
You are so right! I got confused looking at other examples and thought I had to do it like that... tested and working fine, thanks a lot! emoticon