RE: Post Login Action

Arun Pandian, modified 6 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Hi i was trying post login action

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



thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Arun Pandian:

error  : Class com.bm.chat.users.internal.event.PostLogin is not assignable to specified service com.liferay.portal.kernel.events.LifecycleEvent
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.
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.
Arun Pandian, modified 6 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Olaf Kock:

Arun Pandian:

error  : Class com.bm.chat.users.internal.event.PostLogin is not assignable to specified service com.liferay.portal.kernel.events.LifecycleEvent
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.
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?

thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Can you show us the entire class you have written?
Arun Pandian, modified 6 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
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