Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Abdu Zaki
Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
October 20, 2011 8:21 AM
Answer

Abdu Zaki

Rank: New Member

Posts: 21

Join Date: August 24, 2009

Recent Posts

Hi All,

Environment:
Liferay 6.0.5 EE
JBoss: 5.1 EE
OS: Red Hat Enterprise Linux Server release 5.6 (Tikanga)

We developed an extension that uses OrganizationLoclaService to insert organizations at scheduled times. It basically import organizations from a legacy system and insert them into Liferay. This mirror what Liferay base is doing with LDAP import/export. In fact we created a Custom Importer similar to Liferay LDAPImporter and we also extended Liferay LDAPExporter to exports organizations to LDAP.

The problem that we have been seeing is related to the method OrganizationLoclaServiceImpl.addOrganization(..., boolean reindex). But Also with PortalLDAPExporterImpl.addOrganization(...).

1) OrganizationLoclaServiceImpl.addOrganization(..., boolean reindex) is a new method that we added to OrganizationLoclaServiceImpl
2) PortalLDAPExporterImpl.addOrganization(...) is a brand new method added PortalLDAPExporterImpl

The exceptions:
In 1)
13:11:56,551 ERROR Exception in thread "liferay/scheduler_dispatch-5"
13:11:56,552 ERROR java.lang.AbstractMethodError: com.liferay.portal.service.impl.OrganizationLocalServiceImpl.addOrganization(JJLjava/lang/String;Ljava/lang/String;ZJJILjava/lang/String;Lcom/liferay/portal/service/ServiceContext;Z)Lcom/liferay/portal/model/Organization;


In 2)
14:52:28,981 ERROR Exception in thread "liferay/scheduler_dispatch-5"
14:52:28,981 ERROR java.lang.NoSuchMethodError: com.liferay.portal.security.ldap.PortalLDAPExporterUtil.exportToLDAP(JJJ)V


THINGS WE KNOW:
* All the needed JARs are their.
*The service interfaces have been updated
* We cleaned all tmp, jboss temp, work, redeployed many times...nothing helped.
* On development machines and development server it works just fine.
* Prod License was applied.

THINGS WE SUSPECTED:
Class loader problem: Liferay DOES find the our ext plugin, but the Services: OrganizationLoclaServiceImpl, PortalLDAPExporterImpl are not being shadowed, Liferay is using its own version rather than the one in the ext plug in.

Any help, no matter small it is, would be greatly appreciated.

Thanks.
Tomas Polesovsky
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
October 21, 2011 9:04 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 643

Join Date: February 13, 2009

Recent Posts

Hi Abdu,

as I see methods get's called but there is an error. There I assume your Ext Plugin is correctly loaded emoticon

I feel there could be problem in the interfaces (portal-service) reimplementation. Portal obviously doesn't see your custom OrganizationLocalService.addOrganization method and calls the old one (which is not implemented now by your changed *Impl class). There is always problem with overriding the portal-service.jar, classloaders doesn't work for this jar the same way as for portal-impl.jar.

Easy way how to fix it:
1, rewrite portal-service.jar with content of your ext-service-.....jar
2, replace portal-service.jar in your Liferay deployment with this new portal-service.jar

This could work for this time, but you should think of reimplementing it the correct way - see Developing an Ext Plugin, look for section "Changing the API of a core service". If you need I can tell you what exactly you need to do.
Sandra del Moral Lazo
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
September 13, 2013 3:25 AM
Answer

Sandra del Moral Lazo

Rank: New Member

Posts: 23

Join Date: August 7, 2013

Recent Posts

Hi,

I have the same error and I've tried replace .jar but it doesn't work.
This is what I do:

I implement the function in RuleLocalServiceImpl.java:
 1import java.util.Date;
 2import java.util.List;
 3
 4import com.liferay.portal.kernel.dao.orm.DynamicQuery;
 5import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
 6import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
 7import com.liferay.portal.kernel.exception.SystemException;
 8import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
 9import com.segmentationPortlet.service.RuleLocalServiceUtil;
10import com.segmentationPortlet.service.base.RuleLocalServiceBaseImpl;
11import com.segmentationPortlet.model.Rule;
12
13
14/**
15 * The implementation of the rule local service.
16 *
17 * <p>
18 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.segmentationPortlet.service.RuleLocalService} interface.
19 *
20 * <p>
21 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
22 * </p>
23 *
24 * @author sdelmora
25 * @see com.segmentationPortlet.service.base.RuleLocalServiceBaseImpl
26 * @see com.segmentationPortlet.service.RuleLocalServiceUtil
27 */
28public class RuleLocalServiceImpl extends RuleLocalServiceBaseImpl {
29    /*
30     * NOTE FOR DEVELOPERS:
31     *
32     * Never reference this interface directly. Always use {@link com.segmentationPortlet.service.RuleLocalServiceUtil} to access the rule local service.
33     */
34    public List<Rule> getActiveRule(Date lastLogin) throws SystemException {
35        DynamicQuery dq_rules = DynamicQueryFactoryUtil.forClass(Rule.class, PortalClassLoaderUtil.getClassLoader())
36            .add(PropertyFactoryUtil.forName("modifiedDate").ge(lastLogin))
37            .add(PropertyFactoryUtil.forName("status").eq(true));
38
39        List<Rule> listRules = RuleLocalServiceUtil.dynamicQuery(dq_rules);
40        return listRules;
41    }
42}

Then I go to service.xml and build service again, after it I deploy the portlet, move the .jar to /tomcat/lib/ext and stop the tomcat. I start again tomcat and call the function since the hook:
1
2            Date lastLogin = user.getLastLoginDate();
3            List<Rule> listRule = RuleLocalServiceUtil.getActiveRule(lastLogin);

I compile and try to execute but it doesn't work.


13-sep-2013 10:12:08 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: El Servlet.service() para el servlet [Main Servlet] en el contexto con ruta [] lanzó la excepción [La ejecución del Servlet lanzó una excepción] con causa raíz
java.lang.NoSuchMethodError: com.segmentationPortlet.service.RuleLocalServiceUtil.getActiveRule(Ljava/util/Date;)Ljava/util/List;
at com.segmentationProjecthookLogin.hook.LoginAction.run(LoginAction.java:30)
at com.liferay.portal.kernel.events.InvokerAction.run(InvokerAction.java:41)
at com.liferay.portal.events.EventsProcessorImpl.processEvent(EventsProcessorImpl.java:81)
at com.liferay.portal.events.EventsProcessorImp


Any idea to solve the problem?

Thanks!
Jose Jimenez
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
September 13, 2013 5:21 AM
Answer

Jose Jimenez

LIFERAY STAFF

Rank: Regular Member

Posts: 151

Join Date: August 22, 2012

Recent Posts

Hi Sandra,

Do you have the same class in other .jar ?

You can check where the Portal is loading your class using the next Groovy script, Go to Control Panel > Server Administration > Script - select Groovy and execute:


out.println( "Portal loads the service from: " + com.segmentationPortlet.service.RuleLocalServiceUtil.class.getClassLoader().getResource("com/segmentationPortlet/service/RuleLocalServiceUtil.class") )

And check where the hook is loading the class, adding to your custom LoginAction:

System.out.println("Hook loads the service from: " +com.segmentationPortlet.service.RuleLocalServiceUtil.class.getClassLoader().getResource("com/segmentationPortlet/service/RuleLocalServiceUtil.class") );

The same code is valid to check the locations of RuleLocalServiceImpl.class.

I hope this helps you to find the error.
Kind regards,
Jose
Sandra del Moral Lazo
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
September 18, 2013 1:31 AM
Answer

Sandra del Moral Lazo

Rank: New Member

Posts: 23

Join Date: August 7, 2013

Recent Posts

I don't have another .jar with the same class.
I check what the portal is loading and I discover that the Grovy script output is :
Output
Portal loads the service from: jar:file:/C:/Users/sdelmora/Code%20Home/bundles/liferay-portal-6.1.20-ee-ga2/tomcat-7.0.27/lib/ext/SegmentationProject-portlet-service.jar!/com/segmentationPortlet/service/RuleLocalServiceUtil.class


But the hook is loading a .jar that is in /temp/
Hook loads the service from: jar:file:/C:/Users/sdelmora/Code%20Home/bundles/liferay-portal-6.1.20-ee-ga2/tomcat-7.0.27/temp/2-SegmentationProject-hook/WEB-INF/lib/SegmentationProject-portlet-service.jar!/com/segmentationPortlet/service/RuleLocalServiceUtil.class


Is it ok? Or what I have to do to correct this error?

I try to delete the file of /temp/ that was loading the hook, but when I start tomcat it generate again.

Thank you very much!
Jose Jimenez
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
September 18, 2013 3:18 AM
Answer

Jose Jimenez

LIFERAY STAFF

Rank: Regular Member

Posts: 151

Join Date: August 22, 2012

Recent Posts

Hi Sandra,

You have duplicated interfaces, may be in the past you put it manually into the TOMCAT/lib/ext to share this API to other plugins or the portal. In this case, you only have to overwrite <TOMCAT>/lib/ext/sample-portlet-service.jar with the updated <TOMCAT>/webapps/sample-portlet/WEB-INF/lib/sample-portlet-service.jar, and delete from <TOMCAT>/webapps/sample-portlet/WEB-INF/lib/sample-portlet-service.jar to avoid duplicate classes.

(if you don't need to share this jar, symply, delete <TOMCAT>/lib/ext/sample-portlet-service.jar)

Kind regards!
Jose Jimenez
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
September 18, 2013 3:33 AM
Answer

Jose Jimenez

LIFERAY STAFF

Rank: Regular Member

Posts: 151

Join Date: August 22, 2012

Recent Posts

BTW: same for hooks!
Sandra del Moral Lazo
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
September 21, 2013 9:17 AM
Answer

Sandra del Moral Lazo

Rank: New Member

Posts: 23

Join Date: August 7, 2013

Recent Posts

Thank you very much! It works!
Jose Jimenez
RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl
September 22, 2013 1:39 PM
Answer

Jose Jimenez

LIFERAY STAFF

Rank: Regular Member

Posts: 151

Join Date: August 22, 2012

Recent Posts

You are welcome emoticon