Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Post Login Action
Hi i was trying post login action
but i am facing some strange error
but i am facing some strange error
error : Class com.bm.chat.users.internal.event.PostLogin is not assignable to specified service com.liferay.portal.kernel.events.LifecycleEvent
Arun Pandian:
When you look at your code (specifically the "implements" or "extends" part of your class): Is this true? Then you'll know what to do.
error : Class com.bm.chat.users.internal.event.PostLogin is not assignable to specified service com.liferay.portal.kernel.events.LifecycleEvent
If you think that your code is right, you might include the base class, e.g. you might have specified compileInclude, where you should have specified compileOnly in your build.gradle.
Olaf Kock:
Arun Pandian:When you look at your code (specifically the "implements" or "extends" part of your class): Is this true? Then you'll know what to do.
error : Class com.bm.chat.users.internal.event.PostLogin is not assignable to specified service com.liferay.portal.kernel.events.LifecycleEvent
If you think that your code is right, you might include the base class, e.g. you might have specified compileInclude, where you should have specified compileOnly in your build.gradle.
i am using implements LifecycleAction it is a interface and when i checked at gradle i am using compileOnly
And i do imported kernel in my gradle
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
Any ideas?
Can you show us the entire class you have written?
Andrew Jardine:
Can you show us the entire class you have written?
Sure...
package com.bm.chat.users.internal.event;import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.events.LifecycleAction;
import com.liferay.portal.kernel.events.LifecycleEvent;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Portal;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.Validator;@Component(immediate = true, property = { "key=" + PropsKeys.LOGIN_EVENTS_POST }, service = LifecycleEvent.class)public class PostLogin implements LifecycleAction {
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent)
throws ActionException { try {
String ppid = ParamUtil.getString(
lifecycleEvent.getRequest(), "p_p_id"); String portletNamespace = _portal.getPortletNamespace(ppid); String memberRequestKey = ParamUtil.getString(
lifecycleEvent.getRequest(), portletNamespace.concat("key")); if (Validator.isNull(memberRequestKey)) {
return;
} User user = _portal.getUser(lifecycleEvent.getRequest()); }
catch (Exception e) {
throw new ActionException(e);
}
}
@Reference(unbind = "-")
protected void setPortal(Portal portal) {
_portal = portal;
} private Portal _portal;
}
The above code was implemented with the reference of https://github.com/liferay/com-liferay-invitation/blob/master/invitation-invite-members-service/src/main/java/com/liferay/invitation/invite/members/internal/events/LoginPostAction.java