Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-40959

CDIContextListener sets BeanManager to null when registered as a listener in WEB-INF/web.xml

    Details

      Description

      The CDIContextListener.java class is annotated with @WebListener in order to provide zero-config registration.

      However, if the developer also registers it manually in WEB-INF/web.xml like this:

      <listener>
      	<listener-class&gt;com.liferay.cdi.portlet.bridge.CDIContextListener</listener-class&gt;
      </listener>
      

      ... then it will get registered twice. The purpose of the listener is to provide discovery of the CDI BeanManager at startup. Currently there is a bug such that if the listener gets registered twice, then it will set the value of the BeanManager to null.

      Steps to Reproduce:

      1. Build Liferay Faces from source with the jboss profile. This would require step 4 of the wiki article to be:

      mvn -P jboss clean package

      2. Deploy demos/bridge/jsf2-cdi-portlet/target/jsf2-cdi-portlet*.war to Liferay Portal 6.1.2 CE GA3 running on JBoss AS7

      3. Add the portlet to a portal page

      4. Refresh the page

      5. Fill out the form and ensure that the portlet works

      7. Shutdown JBoss AS7

      8. Start JBoss AS7

      If the bug still exists, then after the portal starts, then the following stacktrace will appear in the JBoss server console log:

      16:12:34,741 INFO  [stdout] (MSC service thread 1-11) 16:12:34,739 ERROR [MSC service thread 1-11][CDIContextListener:66] javax.naming.NameNotFoundException: env/BeanManager -- service jboss.naming.context.java.module.ROOT.ROOT.env.BeanManager
      16:12:34,742 INFO  [stdout] (MSC service thread 1-11) javax.naming.NameNotFoundException: env/BeanManager -- service jboss.naming.context.java.module.ROOT.ROOT.env.BeanManager
      16:12:34,742 INFO  [stdout] (MSC service thread 1-11) 	at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
      16:12:34,742 INFO  [stdout] (MSC service thread 1-11) 	at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
      16:12:34,743 INFO  [stdout] (MSC service thread 1-11) 	at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:123)
      16:12:34,743 INFO  [stdout] (MSC service thread 1-11) 	at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)
      16:12:34,743 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.security.pacl.jndi.SchemeAwareContextWrapper.lookup(SchemeAwareContextWrapper.java:200)
      16:12:34,743 INFO  [stdout] (MSC service thread 1-11) 	at javax.naming.InitialContext.lookup(InitialContext.java:392)
      16:12:34,744 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.cdi.portlet.bridge.CDIContextListener.contextInitialized(CDIContextListener.java:61)
      16:12:34,744 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.kernel.servlet.SecurePluginContextListener.instantiatingListener(SecurePluginContextListener.java:347)
      16:12:34,744 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.kernel.servlet.SecurePluginContextListener.instantiatingListeners(SecurePluginContextListener.java:163)
      16:12:34,745 INFO  [stdout] (MSC service thread 1-11) 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      16:12:34,745 INFO  [stdout] (MSC service thread 1-11) 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      16:12:34,745 INFO  [stdout] (MSC service thread 1-11) 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      16:12:34,745 INFO  [stdout] (MSC service thread 1-11) 	at java.lang.reflect.Method.invoke(Method.java:597)
      16:12:34,746 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.doInvokeDeploy(ServletContextListenerHotDeployListener.java:73)
      16:12:34,746 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.deploy.hot.ServletContextListenerHotDeployListener.invokeDeploy(ServletContextListenerHotDeployListener.java:37)
      16:12:34,746 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:195)
      16:12:34,747 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:97)
      16:12:34,747 INFO  [stdout] (MSC service thread 1-11) 	at sun.reflect.GeneratedMethodAccessor499.invoke(Unknown Source)
      16:12:34,747 INFO  [stdout] (MSC service thread 1-11) 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      16:12:34,747 INFO  [stdout] (MSC service thread 1-11) 	at java.lang.reflect.Method.invoke(Method.java:597)
      16:12:34,748 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.security.lang.DoPrivilegedHandler.doInvoke(DoPrivilegedHandler.java:88)
      16:12:34,748 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.security.lang.DoPrivilegedHandler.invoke(DoPrivilegedHandler.java:56)
      16:12:34,748 INFO  [stdout] (MSC service thread 1-11) 	at com.sun.proxy.$Proxy87.fireDeployEvent(Unknown Source)
      16:12:34,748 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
      16:12:34,749 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:164)
      16:12:34,749 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:154)
      16:12:34,749 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)
      16:12:34,749 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.kernel.util.PortalLifecycleUtil.flushInits(PortalLifecycleUtil.java:48)
      16:12:34,750 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.servlet.MainServlet.initPlugins(MainServlet.java:847)
      16:12:34,750 INFO  [stdout] (MSC service thread 1-11) 	at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:366)
      16:12:34,750 INFO  [stdout] (MSC service thread 1-11) 	at javax.servlet.GenericServlet.init(GenericServlet.java:242)
      16:12:34,750 INFO  [stdout] (MSC service thread 1-11) 	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202)
      16:12:34,751 INFO  [stdout] (MSC service thread 1-11) 	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102)
      16:12:34,751 INFO  [stdout] (MSC service thread 1-11) 	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655)
      16:12:34,752 INFO  [stdout] (MSC service thread 1-11) 	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873)
      16:12:34,752 INFO  [stdout] (MSC service thread 1-11) 	at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
      16:12:34,753 INFO  [stdout] (MSC service thread 1-11) 	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      16:12:34,753 INFO  [stdout] (MSC service thread 1-11) 	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      16:12:34,753 INFO  [stdout] (MSC service thread 1-11) 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      16:12:34,754 INFO  [stdout] (MSC service thread 1-11) 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      16:12:34,754 INFO  [stdout] (MSC service thread 1-11) 	at java.lang.Thread.run(Thread.java:680)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                brian.chan Brian Chan
                Reporter:
                neil.griffin Neil Griffin
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 20 weeks, 2 days ago

                  Packages

                  Version Package
                  6.1.X EE
                  6.2.0 CE RC4