4 Replies Latest reply on Apr 28, 2010 3:34 AM by kapitanpetko

    Seam Mail and IceFaces: Problem with Renderer

    ckraus

      Dear all,


      I use seam 2.2.0GA with icefaces 1.8.2 on a jboss server to send emails and it works (nearly) perfect.
      The problem is that if I try to send an email for the first time after rendering the view, I get a NullPointerException thrown after calling the renderer.render(). Every following click on the 'send email' button sends emails as expected.


      Here is the method that renders my mail template:


      @In(create = true)
      private Renderer renderer;
      
      public void sendMail(Mail mail)
      {
          try
          {
              currentMail = mail;
              renderer.render("/system/MailTemplate.xhtml");
              facesMessages.add("Email sent successfully");
          }
          catch(Exception e)
          {
              facesMessages.add("Email sending failed: " + e);
          }
      }
      



      Here is my mail template:


      <m:message xmlns:m="http://jboss.com/products/seam/mail"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 importance="high">
          <m:from name="#{currentMail.from.firstname} #{currentMail.from.lastname}"
                  address="#{currentMail.from.email}"/>
          <m:to name="#{currentMail.to.firstname} #{currentMail.to.lastname}" address="#{currentMail.to.email}"/>
          <ui:repeat var="_receiver" value="#{currentMail.ccReceivers}">
              <m:cc name="#{_receiver.firstname} #{_receiver.lastname}" address="#{_receiver.email}"/>
          </ui:repeat>
          <m:subject>#{currentMail.subject}</m:subject>
          <m:body>
              <html>
              <body>
              <p>Dear #{currentMail.to.firstname} #{currentMail.to.lastname},</p>
              <p/>
              <p>#{currentMail.body}</p>
              <p>#{currentMail.optionalBody ne null ? currentMail.optionalBody : ''}</p>
              <p/>
              <p>Best regards,</p>
              #{currentMail.from.firstname} #{currentMail.from.lastname}
              </body>
              </html>
          </m:body>
      </m:message>
      



      I tried to send the email synchronous as well as asynchonous, but both methods ended in a NullPointerException. I hope anyone can think of my problem.


      Many thanks in advance,
      Chris



        • 1. Re: Seam Mail and IceFaces: Problem with Renderer
          kapitanpetko

          Debug it to see where it fails or at least post the stack trace.

          • 2. Re: Seam Mail and IceFaces: Problem with Renderer
            ckraus

            I forgot to mention, that I use JSF-Delegation.
            Here is a part from my web.xml:


            <context-param>
                 <param-name>com.icesoft.faces.synchronousUpdate</param-name>
                 <param-value>true</param-value>
             </context-param>
             <context-param>
                 <param-name>com.icesoft.faces.doJSFStateManagement</param-name>
                 <param-value>true</param-value>
             </context-param>
             <context-param>
                 <param-name>com.icesoft.faces.standardRequestScope</param-name>
                 <param-value>true</param-value>
             </context-param>
             <context-param>
                 <param-name>com.icesoft.faces.concurrentDOMViews</param-name>
                 <param-value>true</param-value>
             </context-param>
             <context-param>
                 <param-name>com.icesoft.faces.blockUIonSubmit</param-name>
                 <param-value>false</param-value>
             </context-param>
             <context-param>
                 <param-name>com.icesoft.faces.delegateNonIface</param-name>
                 <param-value>true</param-value>
             </context-param>
             
             <!-- servlets -->
             <servlet>
                 <servlet-name>Faces Servlet</servlet-name>
                 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                 <load-on-startup>1</load-on-startup>
             </servlet>
             <servlet>
                 <servlet-name>Seam Resource Servlet</servlet-name>
                 <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
             </servlet>
             <servlet>
                 <servlet-name>Persistent Faces Servlet</servlet-name>
                 <servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class>
                 <load-on-startup>1</load-on-startup>
             </servlet>
             <servlet>
                 <servlet-name>Blocking Servlet</servlet-name>
                 <servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class>
                 <load-on-startup>1</load-on-startup>
             </servlet>
             <servlet>
                 <servlet-name>uploadServlet</servlet-name>
                 <servlet-class>com.icesoft.faces.component.inputfile.FileUploadServlet</servlet-class>
                 <load-on-startup>1</load-on-startup>
             </servlet>
             <servlet>
                 <servlet-name>Download Servlet</servlet-name>
                 <servlet-class>de.einhell.EPAProt.web.util.DownloadServlet</servlet-class>
             </servlet>
             <servlet>
                 <servlet-name>Document Store Servlet</servlet-name>
                 <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
             </servlet>
             <servlet-mapping>
                 <servlet-name>Persistent Faces Servlet</servlet-name>
                 <url-pattern>*.seam</url-pattern>
                 <url-pattern>/xmlhttp/*</url-pattern>
             </servlet-mapping>
             <servlet-mapping>
                 <servlet-name>Blocking Servlet</servlet-name>
                 <url-pattern>/block/*</url-pattern>
             </servlet-mapping>
             <servlet-mapping>
                 <servlet-name>Seam Resource Servlet</servlet-name>
                 <url-pattern>/seam/resource/*</url-pattern>
             </servlet-mapping>
             <servlet-mapping>
                 <servlet-name>uploadServlet</servlet-name>
                 <url-pattern>/uploadHtml</url-pattern>
             </servlet-mapping>
             <servlet-mapping>
                 <servlet-name>Document Store Servlet</servlet-name>
                 <url-pattern>*.pdf</url-pattern>
                 <url-pattern>*.xls</url-pattern>
             </servlet-mapping>
             <servlet-mapping>
                 <servlet-name>Faces Servlet</servlet-name>
                  <url-pattern>*.jsf</url-pattern>
             </servlet-mapping>
            



            and my faces-config.xml:


            <faces-config>
                <application>
                    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                </application>
                <application>
                    <view-handler>com.icesoft.faces.facelets.D2DSeamFaceletViewHandler</view-handler>
                    <message-bundle>
                        JSFoverride
                    </message-bundle>
                </application>
                <application>
                    <message-bundle>messages</message-bundle>
                    <locale-config>
                        <default-locale>en</default-locale>
                        <supported-locale>de</supported-locale>
                        <supported-locale>en</supported-locale>
                        <supported-locale>cn</supported-locale>
                    </locale-config>
                </application>
            </faces-config>
            



            I think the configuration is ok because rendering PDFs or Excelsheets works correct.
            I checked if the renderer is NULL, but he isn't.
            I jumped through the code, to see what happens after calling the renderer.render(/system/MailTemplate). After initializing a org.jboss.seam.ui.facelet.RendererRequest object, the run() method is called.
            Everything works fine... The renderFacelet is called and the facesContext is released and cleaned up. I really don't know, why and where the NullPointerException is thrown, because everything seems to work like expected.
            I really hope you can help me...

            • 3. Re: Seam Mail and IceFaces: Problem with Renderer
              ckraus

              Here is the stack trace:



              09:35:30,535 ERROR [STDERR] java.lang.NullPointerException
              09:35:30,550 ERROR [STDERR]      at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java:873)
              09:35:30,550 ERROR [STDERR]      at javax.mail.internet.InternetAddress.validate(InternetAddress.java:856)
              09:35:30,550 ERROR [STDERR]      at org.jboss.seam.mail.ui.AddressComponent.getInternetAddress(AddressComponent.java:39)
              09:35:30,550 ERROR [STDERR]      at org.jboss.seam.mail.ui.UIFrom.encodeBegin(UIFrom.java:27)
              09:35:30,550 ERROR [STDERR]      at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:172)
              09:35:30,566 ERROR [STDERR]      at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)
              09:35:30,566 ERROR [STDERR]      at org.jboss.seam.mail.ui.UIMessage.encodeChildren(UIMessage.java:192)
              09:35:30,566 ERROR [STDERR]      at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175)
              09:35:30,566 ERROR [STDERR]      at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)
              09:35:30,566 ERROR [STDERR]      at org.jboss.seam.ui.facelet.RendererRequest.renderFacelet(RendererRequest.java:136)
              09:35:30,566 ERROR [STDERR]      at org.jboss.seam.ui.facelet.RendererRequest.run(RendererRequest.java:103)
              09:35:30,566 ERROR [STDERR]      at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:43)
              09:35:30,566 ERROR [STDERR]      at de.einhell.EPAProt.web.util.mail.OppMailManager.sendMail(OppMailManager.java:200)
              09:35:30,582 ERROR [STDERR]      at de.einhell.EPAProt.web.util.mail.OppMailManager.sendEnquiryToReceiver(OppMailManager.java:280)
              09:35:30,582 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              09:35:30,582 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              09:35:30,582 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              09:35:30,582 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:597)
              09:35:30,582 ERROR [STDERR]      at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              09:35:30,582 ERROR [STDERR]      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
              09:35:30,597 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              09:35:30,597 ERROR [STDERR]      at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
              09:35:30,597 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              09:35:30,597 ERROR [STDERR]      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
              09:35:30,597 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              09:35:30,597 ERROR [STDERR]      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              09:35:30,597 ERROR [STDERR]      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              09:35:30,613 ERROR [STDERR]      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              09:35:30,613 ERROR [STDERR]      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
              09:35:30,613 ERROR [STDERR]      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
              09:35:30,613 ERROR [STDERR]      at de.einhell.EPAProt.web.util.mail.OppMailManager_$$_javassist_seam_25.sendEnquiryToReceiver(OppMailManager_$$_javassist_seam_25.java)
              09:35:30,613 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              09:35:30,613 ERROR [STDERR]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              09:35:30,613 ERROR [STDERR]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              09:35:30,629 ERROR [STDERR]      at java.lang.reflect.Method.invoke(Method.java:597)
              09:35:30,629 ERROR [STDERR]      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
              09:35:30,629 ERROR [STDERR]      at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
              09:35:30,629 ERROR [STDERR]      at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
              09:35:30,629 ERROR [STDERR]      at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
              09:35:30,629 ERROR [STDERR]      at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
              09:35:30,629 ERROR [STDERR]      at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
              09:35:30,629 ERROR [STDERR]      at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
              09:35:30,644 ERROR [STDERR]      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
              09:35:30,644 ERROR [STDERR]      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
              09:35:30,644 ERROR [STDERR]      at javax.faces.component.UICommand.broadcast(UICommand.java:387)
              09:35:30,644 ERROR [STDERR]      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
              09:35:30,644 ERROR [STDERR]      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:755)
              09:35:30,644 ERROR [STDERR]      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
              09:35:30,644 ERROR [STDERR]      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              09:35:30,644 ERROR [STDERR]      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:31)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
              09:35:30,660 ERROR [STDERR]      at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
              09:35:30,675 ERROR [STDERR]      at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:26)
              09:35:30,675 ERROR [STDERR]      at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
              09:35:30,675 ERROR [STDERR]      at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
              09:35:30,675 ERROR [STDERR]      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
              09:35:30,675 ERROR [STDERR]      at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
              09:35:30,675 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              09:35:30,675 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              09:35:30,675 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              09:35:30,691 ERROR [STDERR]      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
              09:35:30,691 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              09:35:30,691 ERROR [STDERR]      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              09:35:30,691 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              09:35:30,691 ERROR [STDERR]      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              09:35:30,691 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              09:35:30,691 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
              09:35:30,707 ERROR [STDERR]      at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              09:35:30,707 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              09:35:30,707 ERROR [STDERR]      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              09:35:30,707 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              09:35:30,707 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              09:35:30,707 ERROR [STDERR]      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              09:35:30,707 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              09:35:30,707 ERROR [STDERR]      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              09:35:30,722 ERROR [STDERR]      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              09:35:30,722 ERROR [STDERR]      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              09:35:30,722 ERROR [STDERR]      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              09:35:30,722 ERROR [STDERR]      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              09:35:30,722 ERROR [STDERR]      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              09:35:30,722 ERROR [STDERR]      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              09:35:30,722 ERROR [STDERR]      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              09:35:30,722 ERROR [STDERR]      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              09:35:30,738 ERROR [STDERR]      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              09:35:30,738 ERROR [STDERR]      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              09:35:30,738 ERROR [STDERR]      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              09:35:30,738 ERROR [STDERR]      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              09:35:30,738 ERROR [STDERR]      at java.lang.Thread.run(Thread.java:619)



              • 4. Re: Seam Mail and IceFaces: Problem with Renderer
                kapitanpetko

                The 'from' address is null for some reason, check your code.