留言板

Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

Abdu Zaki,修改在12 年前。

Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

New Member 帖子: 21 加入日期: 09-8-24 最近的帖子
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 [STDERR] Exception in thread "liferay/scheduler_dispatch-5"
13:11:56,552 ERROR [STDERR] 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 [STDERR] Exception in thread "liferay/scheduler_dispatch-5"
14:52:28,981 ERROR [STDERR] 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.
thumbnail
Tomáš Polešovský,修改在12 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

Liferay Master 帖子: 676 加入日期: 09-2-13 最近的帖子
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,修改在10 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

New Member 帖子: 23 加入日期: 13-8-7 最近的帖子
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:
import java.util.Date;
import java.util.List;

import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
import com.segmentationPortlet.service.RuleLocalServiceUtil;
import com.segmentationPortlet.service.base.RuleLocalServiceBaseImpl;
import com.segmentationPortlet.model.Rule;


/**
 * The implementation of the rule local service.
 *
 * <p>
 * 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.
 *
 * </p><p>
 * 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.
 * </p>
 *
 * @author sdelmora
 * @see com.segmentationPortlet.service.base.RuleLocalServiceBaseImpl
 * @see com.segmentationPortlet.service.RuleLocalServiceUtil
 */
public class RuleLocalServiceImpl extends RuleLocalServiceBaseImpl {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never reference this interface directly. Always use {@link com.segmentationPortlet.service.RuleLocalServiceUtil} to access the rule local service.
	 */
	public List<rule> getActiveRule(Date lastLogin) throws SystemException {
		DynamicQuery dq_rules = DynamicQueryFactoryUtil.forClass(Rule.class, PortalClassLoaderUtil.getClassLoader())
			.add(PropertyFactoryUtil.forName("modifiedDate").ge(lastLogin))
			.add(PropertyFactoryUtil.forName("status").eq(true));

		List<rule> listRules = RuleLocalServiceUtil.dynamicQuery(dq_rules);
		return listRules;
	}
}</rule></rule>

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:

			Date lastLogin = user.getLastLoginDate();
			List<rule> listRule = RuleLocalServiceUtil.getActiveRule(lastLogin);
</rule>

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!
thumbnail
Jose Jiménez,修改在10 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

Regular Member 帖子: 176 加入日期: 12-8-23 最近的帖子
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,修改在10 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

New Member 帖子: 23 加入日期: 13-8-7 最近的帖子
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!
thumbnail
Jose Jiménez,修改在10 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

Regular Member 帖子: 176 加入日期: 12-8-23 最近的帖子
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!
thumbnail
Jose Jiménez,修改在10 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

Regular Member 帖子: 176 加入日期: 12-8-23 最近的帖子
BTW: same for hooks!
Sandra del Moral Lazo,修改在10 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

New Member 帖子: 23 加入日期: 13-8-7 最近的帖子
Thank you very much! It works!
thumbnail
Jose Jiménez,修改在10 年前。

RE: Liferay 6.0-Not executing ext OrganizationLocalSeriveImpl

Regular Member 帖子: 176 加入日期: 12-8-23 最近的帖子
You are welcome emoticon