| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 22/04/2010 06:32:21
|
ckraus
Joined: 05/03/2009 00:00:00
Messages: 11
Offline
|
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:
Code:
@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:
Code:
<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
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 22/04/2010 10:05:35
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
are you using jsf-delegation or have you created a wrapper class for the the ExternalContext (ICEfaces uses BridgeExternalContext and seam-mail uses it's own ExternalContext).
If the renderer is null before the first time the button is pressed, you might want to do a check on the getter for the renderer, so that if it's null, then use Component.getInstance(.....) to ensure that you actually have an instance of the renderer before you try and use it (?)...hard to tell what all you have happening on this page. Also, are there any page actions that might be interfering with the renderer?
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 23/04/2010 04:09:09
|
ckraus
Joined: 05/03/2009 00:00:00
Messages: 11
Offline
|
Hi Judy, thanks for your post.
I'm using JSF-Delegation.
Here is a part from my web.xml:
Code:
<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:
Code:
<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...
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 23/04/2010 10:09:43
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
you will have to step through with a debugger to find out what is null. I can't even begin to guess what would be null here (Unless the contexts aren't yet setup when you are trying to trigger the render??). You also haven't posted the stack trace (which will at least give you the line where the NPE occurs so you can inspect all the attributes on that particular line of code).
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 26/04/2010 02:38:15
|
ckraus
Joined: 05/03/2009 00:00:00
Messages: 11
Offline
|
Hello Judy,
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)
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 26/04/2010 09:58:12
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
Looks like your address is null (do a check on that)...but your NPE is really within this checkAddress routine--doesn't look like an issue with ICEfaces by looking at the stack trace. Really go through this stack trace to find your NPE...Perhaps you want to use a default address at the begnining of development to see if this is the case (use your own). If it is sending the email before you are setting the email address, then you will get a copy of every email sent and will figure this out soon enough...hard to say exactly without looking at all the details and giving it a try (not likely unless you are a support customer).
|
|
|
 |
|
|
|
|