1 Reply Latest reply on Aug 6, 2009 6:15 PM by Arbi Sookazian

    Injecting session scoped component to another session scoped component in portlet.

    Jacek Bukowski Newbie

      Hi all,


      I am developing Liferay portlet using ICEfaces and Seam. I hava a permissionService  which is a SFSB Seam component in session scope. The permissionService is injected into session scoped java bean seam component named sampleBean, which I use as a backed bean for the JSF page. The problem is, that if the sampleBean is in APPLICATION or EVENT scope all works fine, but if it is in SESSION scope, then the persmissionService is being created three times (check in debugger by breakpoint in @Created annotated method). The first time @Create method is invoked, the dependencies are properly injected into permissionService, but other two times no injection occurs (the field with @In annotation is null).


      The components are:



      @Name("sampleBean")
      @Scope(ScopeType.SESSION)
      public class SampleBeanImpl implements Serializable, SampleBean {
          
          @In(create = true)
          private PermissionService permissionService;
          
          @Override
          // Method called from JSF page.
          public boolean isMyCustomActionPermission() {
              return permissionService.hasPermission("MY_CUSTOM_ACTION");
          }
          
          @Create
          @Override
          public void create() {
              System.out.println("*******************************************************");
              System.out.println("sampleBean - create");
              System.out.println("*******************************************************");
          }
          
          @Destroy
          @Override
          public void destroy() {
              System.out.println("*******************************************************");
              System.out.println("sampleBean - destroy");
              System.out.println("*******************************************************");
          }
      
      
      @Stateful
      @Name("permissionService")
      @Scope(ScopeType.SESSION)
      public class PermissionServiceImpl implements PermissionService, Serializable {
          private static final long serialVersionUID = 1L;
          
          //
          // facesContext is injected only before first create() method call 
          //
          @In(create = true)
          private FacesContext facesContext;
          
          private long scopeGroupId;
          private String name;
          private String primKey;
          
          private PermissionChecker permissionChecker;
          
          @Override
          public boolean hasPermission(String action) {
              return permissionChecker.hasPermission(scopeGroupId, name, primKey, action);
          }
          
          @Override
          @Create
          public void create() {
              //
              // Here NullPointerException is raised, because facesContext is null
              // 
              ThemeDisplay themeDisplay = (ThemeDisplay) (facesContext.getExternalContext().getRequestMap()
                      .get(WebKeys.THEME_DISPLAY));
              PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
              
              scopeGroupId = themeDisplay.getScopeGroupId();
              name = portletDisplay.getRootPortletId();
              primKey = portletDisplay.getResourcePK();
              permissionChecker = themeDisplay.getPermissionChecker();
          }
          
          @Override
          @Remove
          @Destroy
          public void remove() {
              ;
          }
      }



      I got following exception:


      java.lang.NullPointerException
              at com.recglobal.mojekadry.common.permission.PermissionServiceImpl.create(PermissionServiceImpl.java:48)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
              at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
              at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInter
      ceptor.java:138)
              at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.jav
      a:30)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:83)
              at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:70)
              at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:59)
              at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
              at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
              at sun.reflect.GeneratedMethodAccessor452.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
      
              at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_8952910.invoke
      (InvocationContextInterceptor_z_fillMethod_8952910.java)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
              at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_8952910.invoke(Invo
      cationContextInterceptor_z_setup_8952910.java)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropa
      gationInterceptor.java:60)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerIntercep
      tor.java:56)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:2
      01)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
      
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:219)
              at org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase.invoke(ProxyInvocationHandlerBase.java:261)
              at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationH
      andlerBase.java:101)
              at $Proxy794.create(Unknown Source)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
              at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:43)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
              at org.javassist.tmp.java.lang.Object_$$_javassist_seam_7.create(Object_$$_javassist_seam_7.java)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
              at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
              at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
              at org.jboss.seam.Component.newInstance(Component.java:2132)
              at org.jboss.seam.Component.getInstance(Component.java:2021)
              at org.jboss.seam.Component.getInstance(Component.java:1983)
              at org.jboss.seam.Component.getInstance(Component.java:1977)
              at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2349)
              at org.jboss.seam.Component.getValueToInject(Component.java:2301)
              at org.jboss.seam.Component.injectAttributes(Component.java:1736)
              at org.jboss.seam.Component.inject(Component.java:1554)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:118)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
              at com.recglobal.mojekadry.expenses.gui.sample.beans.SampleBeanImpl_$$_javassist_seam_6.toString(SampleBeanImpl_
      $$_javassist_seam_6.java)
              at java.lang.String.valueOf(String.java:2826)
              at com.liferay.util.portlet.PortletRequestUtil._isValidAttributeValue(PortletRequestUtil.java:491)
              at com.liferay.util.portlet.PortletRequestUtil.toXML(PortletRequestUtil.java:261)
              at com.liferay.portal.velocity.VelocityVariables.insertVariables(VelocityVariables.java:382)
              at com.liferay.taglib.util.ThemeUtil.includeVM(ThemeUtil.java:179)
              at com.liferay.taglib.util.ThemeUtil.include(ThemeUtil.java:68)
              at com.liferay.taglib.theme.WrapPortletTag.doEndTag(WrapPortletTag.java:114)
              at org.apache.jsp.html.common.themes.portlet_jsp._jspService(portlet_jsp.java:2832)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
              at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)
              at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)
              at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
              at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:611)
              at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
              at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
              at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
              at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
              at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
              at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1866)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
              at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)
              at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)
              at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:2884)
              at com.liferay.portal.util.PortalUtil.renderPortlet(PortalUtil.java:897)
              at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:170)
              at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processPortlet(RuntimePortletUtil.java:103)
              at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processTemplate(RuntimePortletUtil.java:281)
              at com.liferay.portlet.layoutconfiguration.util.RuntimePortletUtil.processTemplate(RuntimePortletUtil.java:190)
              at org.apache.jsp.html.portal.layout.view.portlet_jsp._jspService(portlet_jsp.java:831)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
              at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)
              at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)
              at com.liferay.portal.action.LayoutAction.includeLayoutContent(LayoutAction.java:294)
              at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:471)
              at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:195)
              at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
              at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
              at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:157)
              at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
              at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
              at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:608)
              at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:846)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
              at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)
              at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
              at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
              at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:143)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:142)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:94)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:140)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:282)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:94)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.cache.CacheFilter.processFilter(CacheFilter.java:425)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:257)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.sso.opensso.OpenSSOFilter.processFilter(OpenSSOFilter.java:73)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:193)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:191)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.servlet.filters.threadlocalcache.ThreadLocalCacheFilter.processFilter(ThreadLocalCacheFilt
      er.java:55)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:91)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:154)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:94)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.jav
      a:126)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java
      :70)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)




      If I change scope of sampleBean to EVENT or APPLICATION it works.


      I don't understand why the persmissionService is created three times and why only during the first time its dependencies are injected.


      I noticed strange thing in above stacktrace, which maybe lead to root cause:


      com.recglobal.mojekadry.expenses.gui.sample.beans.SampleBeanImpl_$$_javassist_seam_6.toString(SampleBeanImpl_
      $$_javassist_seam_6.java)
              at java.lang.String.valueOf(String.java:2826)
              at com.liferay.util.portlet.PortletRequestUtil._isValidAttributeValue(PortletRequestUtil.java:491)
              at com.liferay.util.portlet.PortletRequestUtil.toXML(PortletRequestUtil.java:261)
              at com.liferay.portal.velocity.VelocityVariables.insertVariables(VelocityVariables.java:382)
              at com.liferay.taglib.util.ThemeUtil.includeVM(ThemeUtil.java:179)
              at com.liferay.taglib.util.ThemeUtil.include(ThemeUtil.java:68)
              at com.liferay.taglib.theme.WrapPortletTag.doEndTag(WrapPortletTag.java:114)
              at org.apache.jsp.html.common.themes.portlet_jsp._jspService(portlet_jsp.java:2832)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      



      I don't know why toString() method is being invoked.


      Can someone help me finding the root cause?


      Thanks a lot,
      Jacek