Login hook is not working on production environment Liferay 7.1

Michał Janusz, modified 6 Years ago. New Member Posts: 14 Join Date: 3/8/16 Recent Posts
Hi

I have Liferay 7.1.0-ga1. I create login hook using Liferay Module Project. Hook should redirect user when it is a first login:
@Component(immediate = true, property = { "com.liferay.portlet.display-category=category.sample",
        "com.liferay.portlet.instanceable=true", "javax.portlet.init-param.template-path=/",
        "javax.portlet.init-param.view-template=/view.jsp", "javax.portlet.name=" + LoginHookPortletKeys.LoginHook,
        "javax.portlet.resource-bundle=content.Language", "javax.portlet.security-role-ref=power-user,user",
        "mvc.command.name=/login/login", "javax.portlet.name=com_liferay_login_web_portlet_FastLoginPortlet",
        "javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet",
        "service.ranking:Integer=100" }, service = MVCActionCommand.class)
public class LoginHookPortlet extends BaseMVCActionCommand {

    @Override
    protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
        mvcActionCommand.processAction(actionRequest, actionResponse);
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        long companyId = CompanyThreadLocal.getCompanyId();
        String email = ParamUtil.getString(actionRequest, "login");
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, email);
        if (user != null) {
            ExpandoBridge expandoBridge = user.getExpandoBridge();
            String firstLogin = (String) expandoBridge.getAttribute("firstLogin");
            if (firstLogin.equals("true")) {
                actionResponse.sendRedirect(themeDisplay.getURLMyAccount().toString());
            }
        }

    }

    @Reference(
            target = 
            "(&(mvc.command.name=/login/login)" +
            "(javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet)" +
            "(component.name=com.liferay.login.web.internal.portlet.action.LoginMVCActionCommand))"
            )
    public void setMvcActionCommand(MVCActionCommand mvcActionCommand) {
        this.mvcActionCommand = mvcActionCommand;
    }

    protected MVCActionCommand mvcActionCommand;
}

Is is working ok in local environment but not on production. When I restart production server I get 2 Errors and I think that it can be connect:
2018-10-22 08:35:01.075 ERROR [Framework Event Dispatcher: Equinox Container: 20                                                                                                                                                           744b3f-d5d5-0018-1a5b-89c61a6c3723][javax_enterprise_cdi-api:97] FrameworkEventERROR org.osgi.framework.BundleException: Could not resolve module: javax.enterprise.cdi-api [948]_  Unresolved requirement: Import-Package: javax.inject_ [Sanitized]
       at org.eclipse.osgi.container.Module.start(Module.java:429)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incSta                                                                                                                                                             rtLevel(ModuleContainer.java:1582)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incSta                                                                                                                                                             rtLevel(ModuleContainer.java:1562)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doCont                                                                                                                                                             ainerStartLevel(ModuleContainer.java:1533)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispat                                                                                                                                                             chEvent(ModuleContainer.java:1476)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispat                                                                                                                                                             chEvent(ModuleContainer.java:1)
       at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
       at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
2018-10-22 08:35:01.080 INFO  [Start Level: Equinox Container: 20744b3f-d5d5-001                                                                                                                                                             8-1a5b-89c61a6c3723][BundleStartStopLogger:35] STARTED com.liferay.util.taglib_2.0.0 [951]
2018-10-22 08:35:01.081 INFO  [Start Level: Equinox Container: 20744b3f-d5d5-001                                                                                                                                                             8-1a5b-89c61a6c3723][BundleStartStopLogger:35] STARTED javax.el-api_3.0.0 [952]
2018-10-22 08:35:01.082 INFO  [Start Level: Equinox Container: 20744b3f-d5d5-001                                                                                                                                                             8-1a5b-89c61a6c3723][BundleStartStopLogger:35] STARTED javax.interceptor-api_1.2.0 [953]

2018-10-22 08:35:01.082 INFO  [Start Level: Equinox Container: 20744b3f-d5d5-001                                                                                                                                                             8-1a5b-89c61a6c3723][BundleStartStopLogger:35] STARTED javax.servlet-api_3.0.1 [954]
2018-10-22 08:35:01.087 INFO  [Start Level: Equinox Container: 20744b3f-d5d5-001                                                                                                                                                             8-1a5b-89c61a6c3723][BundleStartStopLogger:35] STARTED portlet-api_3.0.0 [956]
2018-10-22 08:35:01.087 ERROR [Framework Event Dispatcher: Equinox Container: 20                                                                                                                                                             744b3f-d5d5-0018-1a5b-89c61a6c3723][osgi_cmpn:97] FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: osgi.cmpn [955]_ Unresolved requirement: Import-Package: javax.microedition.io; resolution:="optional"  _Unresolved requirement: Import-Package: javax.persistence; version="[1.1.0,2.0.0)"; resolution:="optional"_  Unresolved requirement: Import-Package: javax.servlet; version="[2.5.0,3.0.0)"; resolution:="optional"  _Unresolved requirement: Import-Package: javax.servlet.http; version="[2.5.0,3.0.0)"; resolution:="optional"_  Unresolved requirement: Require-Capability: osgi.compile.time.only; filter:="(&(must.not.resolve=*)(!(must.not.resolve=*)))"_ [Sanitized]
       at org.eclipse.osgi.container.Module.start(Module.java:429)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incSta                                                                                                                                                             rtLevel(ModuleContainer.java:1582)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incSta                                                                                                                                                             rtLevel(ModuleContainer.java:1562)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doCont                                                                                                                                                             ainerStartLevel(ModuleContainer.java:1533)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispat                                                                                                                                                             chEvent(ModuleContainer.java:1476)
       at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispat                                                                                                                                                             chEvent(ModuleContainer.java:1)
       at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
       at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

There are errors in modules which I have never seen before and I did not touch it.
Thank you for help.
Michał Janusz, modified 6 Years ago. New Member Posts: 14 Join Date: 3/8/16 Recent Posts
Resolved. The issue was naming conflict with other bundle. Deploying one bundle was stopping the other one.