0 Replies Latest reply on Sep 9, 2010 3:01 PM by Alex Ka

    Weld + Liferay + Vaadin : Session context not active

    Alex Ka Novice

      Hi,

      I'm trying to use CDI in my Vaadin (6.4.2) portlet. It's deployed with Liferay 6.0.5 which is running on Glassfish 3.0.1. I have extended Vaadin's AbstractApplicationPortlet to get an instance of my Vaadin application from Weld (have it CDI-enabled, if I might say). Here's the code:


      public class ApplicationPortlet extends AbstractApplicationPortlet {
        @Override
        protected Class\<MenuApp\> getApplicationClass() throws ClassNotFoundException {
            return MenuApp.class;
        }
      
        @Override
        protected Application getNewApplication(PortletRequest request) throws PortletException {
          BeanManager manager;
          try {
             manager = (BeanManager) new InitialContext().lookup("java:comp/" + 
                 BeanManager.class.getSimpleName());
          } catch (NamingException e) {
             throw new PortletException("CDI BeanManager not found in lookup", e);
          }
          Bean<?> bean = manager.getBeans(App.class).iterator().next();
          CreationalContext<?> ctx = manager.createCreationalContext(bean);
          return (Application) manager.getReference(bean, MenuApp.class, ctx);
        }
      }
      



      When the portlet is shown at first it appears ok. At a certain time when I refresh the page or try to logon to Liferay, I receive:

      javax.portlet.PortletException: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped


      I noticed several calls from the portlet's servlet and sometimes Weld would get an active session context, sometimes it fails. I'm not sure if the cause is Weld, Portlets, Liferay or Vaadin. But I'm wondering what makes Weld find it's session context only occasionally. Does anyone have experience with Portlets and CDI? Is there something special with session scope?


      Here is the full error log:


        1
        2[#|2010-09-08T16:53:43.293+0300|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=28;_ThreadName=http-thread-pool-8080-(2);|ApplicationDispatcher[/menu-portlet] PWC1231: Servlet.service() for servlet MenuPortlet threw exception
        3javax.portlet.PortletException: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped
        4    at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.handleServiceException(AbstractApplicationPortlet.java:1348)
        5    at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.handleRequest(AbstractApplicationPortlet.java:487)
        6    at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.serveResource(AbstractApplicationPortlet.java:727)
        7    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:119)
        8    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
        9    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:92)
       10    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
       11    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
       12    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:822)
       13    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
       14    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:517)
       15    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:488)
       16    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:379)
       17    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:336)
       18    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314)
       19    at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:635)
       20    at com.liferay.portlet.InvokerPortletImpl.invokeResource(InvokerPortletImpl.java:747)
       21    at com.liferay.portlet.InvokerPortletImpl.serveResource(InvokerPortletImpl.java:504)
       22    at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:847)
       23    at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:602)
       24    at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:229)
       25    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
       26    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
       27    at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:152)
       28    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
       29    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
       30    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
       31    at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:508)
       32    at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:485)
       33    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
       34    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
       35    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
       36    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       37    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       38    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       39    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       40    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       41    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       42    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       43    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       44    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       45    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       46    at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:309)
       47    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
       48    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       49    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       50    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       51    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       52    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       53    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       54    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       55    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       56    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       57    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       58    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       59    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:182)
       60    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
       61    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       62    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       63    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       64    at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:254)
       65    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
       66    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       67    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       68    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:820)
       69    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
       70    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:517)
       71    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:488)
       72    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:379)
       73    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:336)
       74    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:314)
       75    at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:133)
       76    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
       77    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
       78    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
       79    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       80    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       81    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       82    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       83    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       84    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       85    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       86    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       87    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       88    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       89    at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:309)
       90    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
       91    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       92    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       93    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       94    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       95    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
       96    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
       97    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
       98    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
       99    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      100    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      101    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      102    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:182)
      103    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      104    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      105    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      106    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      107    at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:221)
      108    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      109    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      110    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      111    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      112    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
      113    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      114    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      115    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      116    at com.liferay.portal.servlet.filters.cache.CacheFilter.processFilter(CacheFilter.java:440)
      117    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      118    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      119    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      120    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      121    at com.liferay.portal.servlet.filters.etag.ETagFilter.processFilter(ETagFilter.java:45)
      122    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      123    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      124    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      125    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      126    at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:254)
      127    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      128    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      129    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      130    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      131    at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:81)
      132    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      133    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      134    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      135    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      136    at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:179)
      137    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      138    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      139    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      140    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      141    at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:239)
      142    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      143    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      144    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      145    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      146    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
      147    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      148    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      149    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      150    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:126)
      151    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      152    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      153    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
      154    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      155    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      156    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:196)
      157    at com.liferay.portal.servlet.filters.threadlocal.ThreadLocalFilter.processFilter(ThreadLocalFilter.java:35)
      158    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:123)
      159    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      160    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
      161    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
      162    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
      163    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
      164    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
      165    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
      166    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
      167    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
      168    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
      169    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
      170    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      171    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      172    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      173    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      174    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      175    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      176    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      177    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      178    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      179    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      180    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      181    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      182    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      183    at java.lang.Thread.run(Thread.java:619)
      184Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped
      185    at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:679)
      186    at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:138)
      187    at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:100)
      188    at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
      189    at xx.xxx.web.view.MenuApp_$$_javassist_172.isRunning(MenuApp_$$_javassist_172.java)
      190    at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.getExistingApplication(AbstractApplicationPortlet.java:850)
      191    at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.findApplicationInstance(AbstractApplicationPortlet.java:775)
      192    at com.vaadin.terminal.gwt.server.AbstractApplicationPortlet.handleRequest(AbstractApplicationPortlet.java:355)
      193    ... 178 more
      194|#]