2 Replies Latest reply on Sep 30, 2007 4:49 PM by Jarkko Lietolahti

    Seam Mail send exception from portlet

    Tuomas Kassila Newbie

      Seam Mail send exception from portlet

      We got java.lang.IllegalStateException wnen trying to send seam email from a portlet. The same code from seam html page works well.

      renderer.render( email_xhtml_file );

      java.lang.IllegalStateException: Can not call encodeNamespace() during a portlet ActionRequest


      We are using jboss 4.0.5 and seam 1.2.1GA, liferay 4.x
      At the moment we cannot upgrade into newer seam, so:

      Q1: Is there some some bugfixs allready or workarounds to do?

      Here is an exception what we got when trying to send seam email:

      3:48:36,907 ERROR [SendEmail] Error sending mail
      java.lang.IllegalStateException: Can not call encodeNamespace() during a portlet ActionRequest
      at org.apache.myfaces.context.portlet.PortletExternalContextImpl.encodeNamespace (PortletExternalContextImpl.java:189)
      at javax.faces.component.UIViewRoot.createUniqueId(UIViewRoot.java:187)
      at com.sun.facelets.compiler.UIInstructionHandler.apply(UIInstructionHandler.java:90)
      at com.sun.facelets.compiler.NamespaceHandler.apply (NamespaceHandler.java:49)
      at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
      at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
      at org.jboss.seam.ui.facelet.FaceletsRenderer.renderFacelet (FaceletsRenderer.java:149)
      at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:112)
      at fi.tc.business.email.SendEmail.sendThis(SendEmail.java:75)
      at fi.tc.business.email.SendEmail.send (SendEmail.java:87)
      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:20)
      at org.jboss.seam.intercept.RootInvocationContext.proceed (RootInvocationContext.java:31)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
      at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java :47)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java :37)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed (SeamInvocationContext.java:69)
      at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java :69)
      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke (JavaBeanInterceptor.java:87)
      at fi.tc.business.email.SendEmail_$$_javassist_218.send(SendEmail_$$_javassist_218.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.el.util.ReflectionUtil.invokeMethod (ReflectionUtil.java:325)
      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:338)
      at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
      at org.jboss.el.parser.AstValue.invoke (AstValue.java:96)
      at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
      at com.sun.facelets.el.LegacyMethodBinding.invoke (LegacyMethodBinding.java:69)
      at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
      at javax.faces.component.UICommand.broadcast(UICommand.java:106)
      at javax.faces.component.UIViewRoot._broadcastForPhase (UIViewRoot.java:94)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
      at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
      at org.apache.myfaces.lifecycle.LifecycleImpl.execute (LifecycleImpl.java:86)
      at org.apache.myfaces.portlet.MyFacesGenericPortlet.processAction(MyFacesGenericPortlet.java:220)
      at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:88)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:173)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
      at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java :574)
      at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
      at com.liferay.portlet.CachePortlet._invoke(CachePortlet.java:333)
      at com.liferay.portlet.CachePortlet.processAction (CachePortlet.java:157)
      at com.liferay.portal.action.LayoutAction._processPortletRequest(LayoutAction.java:269)
      at com.liferay.portal.action.LayoutAction._processActionRequest(LayoutAction.java:290)
      at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:113)
      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:156)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      at org.apache.struts.action.ActionServlet.doPost (ActionServlet.java:432)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:479)
      at com.liferay.portal.servlet.MainServlet.service (MainServlet.java:877)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:173)
      at com.liferay.filters.strip.StripFilter.doFilter(StripFilter.java:94)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at com.liferay.filters.secure.SecureFilter.doFilter(SecureFilter.java:143)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at com.liferay.filters.compression.CompressionFilter.doFilter(CompressionFilter.java :115)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter.doFilter(LayoutCacheFilter.java:197)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:173)
      at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.doFilter(AutoLoginFilter.java:117)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java :202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:169)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter (ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java :173)
      at net.hyperic.hq.product.servlet.filter.JMXFilter.doFilter(JMXFilter.java:277)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke (JaccContextValve.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection (Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      at java.lang.Thread.run(Thread.java:619)

      Tuomas

        • 1. Re: Seam Mail send exception from portlet
          Pete Muir Master

          First time I've seen this issue. Please file a JIRA issue.

          • 2. Re: Seam Mail send exception from portlet
            Jarkko Lietolahti Novice

            We got past this one by making a modification in org.apache.myfaces.context.portlet.PortletExternalContextImpl

             public String encodeNamespace(String name) {
            
             // changed by jli @ 29.9.2007 to allow seam email
             // generation in portal environment
             if (_isActionRequest) { // encodeNamespace only allowed for
             // RenderRequest
             return name;
             // String msg = "Can not call encodeNamespace() during a portlet
             // ActionRequest";
             // throw new IllegalStateException(msg);
             }
            
             // we render out the name and then the namespace as
             // e.g. for JSF-ids, it is important to keep the _id prefix
             // to know that id creation has happened automatically
             return name + ((RenderResponse) _portletResponse).getNamespace();
             }
            


            We also discovered that you can't use facelet tags (ui: etc) when sending seam email from inside portlet.. So below doesn't work and we had to implement looping outside the template. The bad thing is that also the h: tags don't work..

            <ui:repeat value="#{people}" var="p">
             <m:message>
             <m:from name="#{person.firstname} #{person.lastname}">#{person.address}</m:from>
             <m:to name="#{p.firstname}">#{p.address}</m:to>
             ...
             </m:message>
            </ui:repeat>