Seam Mail Problem NPE
tony.herstell1 Dec 28, 2008 2:20 AMFail to get my email working asynch (very hard to debug!) again (tried this many months ago with no luck but now on Seam 2.1.1.GA and RF 3.2.2.SR1).
Looked again at my non-asynch mail and noticed that an image that should have been there (it used to be!) was no longer there!
<p> <h:graphicImage url="#{basePath}/images/sec_logo_sm.gif" /> </p>
This USED to work... with basePath defined in components.xml:
<!-- Utility bean called "basePath"that allows the pages to reference the basePath for resources Usage: <link rel="stylesheet" type="text/css" href="#{basePath}/xmlhttp/css/xp/xp.css" /> --> <factory name="basePath" value="#{facesContext.externalContext.request.scheme}://#{facesContext.externalContext.request.serverName}:#{facesContext.externalContext.request.serverPort}#{facesContext.externalContext.request.contextPath}/" />
Floundered in doco and found that adding urlBase into the m tag was supposed to help.. but it didn't...
<m:message urlBase="#{basePath}">
humm...
Resported to:
<p> <h:graphicImage url="http://www.selwynequestriancentre.co.nz/site/images/sec_logo_sm.gif" /> </p>
and this works again in non-asynch.
aysnch still fails with NPE
14:12:13,955 ERROR [STDERR] java.lang.NullPointerException 14:12:13,955 ERROR [STDERR] at javax.mail.internet.MimeUtility.checkAscii(MimeUtility.java:1286) 14:12:13,955 ERROR [STDERR] at javax.mail.internet.MimeUtility.encodeWord(MimeUtility.java:613) 14:12:13,955 ERROR [STDERR] at javax.mail.internet.MimeUtility.encodeText(MimeUtility.java:444) 14:12:13,955 ERROR [STDERR] at javax.mail.internet.MimeMessage.setSubject(MimeMessage.java:793) 14:12:13,955 ERROR [STDERR] at org.jboss.seam.mail.ui.UISubject.encodeChildren(UISubject.java:29) 14:12:13,955 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175) 14:12:13,955 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163) 14:12:13,955 ERROR [STDERR] at org.jboss.seam.mail.ui.UIMessage.encodeChildren(UIMessage.java:192) 14:12:13,955 ERROR [STDERR] at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886) 14:12:13,955 ERROR [STDERR] at com.sun.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:50) 14:12:13,955 ERROR [STDERR] at com.sun.facelets.component.UIRepeat.process(UIRepeat.java:357) 14:12:13,955 ERROR [STDERR] at com.sun.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:617) 14:12:13,955 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175) 14:12:13,955 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)
based on:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:repeat value="#{recipients}" var="eachRecipient" xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://jboss.com/products/seam/mail" xmlns:h="http://java.sun.com/jsf/html" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets"> <m:message urlBase="#{basePath}"> <m:from name="Selwyn Equestrian Centre" address="tony.herstell@selwynequestriancentre.co.nz" /> <s:fragment rendered="#{(eachRecipient.firstname ne null)}"> <m:to name="#{eachRecipient.firstname} #{eachRecipient.surname}">#{eachRecipient.email}</m:to> </s:fragment> <s:fragment rendered="#{(eachRecipient.firstname eq null)}"> <m:to>#{eachRecipient.email}</m:to> </s:fragment> <m:replyTo name="Selwyn Equestrian Centre" address="tony.herstell@selwynequestriancentre.co.nz" /> <m:subject>#{subjectText}</m:subject> <m:body> <table> <tr> <s:fragment rendered="#{!(eachRecipient.firstname eq null) or (eachRecipient.firstname eq '')}"> <td width="50%" align="left"> <h:outputText value="Dear #{eachRecipient.firstname}" /> </td> </s:fragment> <s:fragment rendered="#{eachRecipient.avatar ne null}"> <td width="50%" align="center"> <m:attachment rendered="#{eachRecipient.avatar ne null}" value="#{eachRecipient.avatar.image}" fileName="#{eachRecipient.avatar.name}" contentType="#{eachRecipient.avatar.type}" status="avatar" disposition="inline" /> <img src="cid:#{avatar.contentId}" /> </td> </s:fragment> </tr> </table> <p> <s:formattedText value="#{messageText}"/> </p> <p> <h:outputText value="#{messages.email_sec}" /> </p> <center> <hr/> <p> <h:graphicImage url="http://www.selwynequestriancentre.co.nz/site/images/sec_logo_sm.gif" /> </p> <p> <h:outputText value="#{messages.email_website_sec}" /> </p> <p> <i> <h:outputText value="#{messages.mailing_list_remove_from_list}" /> </i> </p> <hr/> </center> </m:body> </m:message> </ui:repeat>
Question 1.
Is this a bug (why would basepath no longer work seems wrong to be adding in a full url)?
Question 2.
Why would the asynch throw a NPE.. whats the difference?