Aynch Mail Sender Fails but Normal Does'nt
tony.herstell1 Aug 9, 2008 8:36 AMAll I do is move my email sending to an Asynch routine and I get this:
18:30:50,457 INFO [AsynchronousMailProcessorImpl] > scheduleSend 18:30:50,738 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/jboss-seam-mail.jar!/META-INF/seam-mail.taglib.xml 18:30:50,753 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/jboss-seam-ui.jar!/META-INF/s.taglib.xml 18:30:50,753 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-core.taglib.xml 18:30:50,769 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-html.taglib.xml 18:30:50,769 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-ui.taglib.xml 18:30:50,769 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-core.taglib.xml 18:30:50,785 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-fn.taglib.xml 18:30:50,785 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/richfaces-ui-3.2.1.GA.jar!/META-INF/a4j.taglib.xml 18:30:50,800 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/richfaces-ui-3.2.1.GA.jar!/META-INF/ajax4jsf.taglib.xml 18:30:50,800 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/richfaces-ui-3.2.1.GA.jar!/META-INF/jsp.taglib.xml 18:30:50,816 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/richfaces-ui-3.2.1.GA.jar!/META-INF/rich.taglib.xml 18:30:50,832 ERROR [STDERR] 9/08/2008 18:30:50 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/C:/jboss-4.2.1.GA/server/selwyn/deploy/Sec.ear/SecWeb.war/WEB-INF/lib/richfaces-ui-3.2.1.GA.jar!/META-INF/richfaces.taglib.xml 18:30:51,144 INFO [MailSession] Creating JavaMail Session (smtp.gmail.com:465) 18:30:51,144 INFO [MailSession] connected to mail server 18:30:51,207 ERROR [STDERR] java.lang.NullPointerException 18:30:51,207 ERROR [STDERR] at javax.mail.internet.MimeUtility.checkAscii(MimeUtility.java:1286) 18:30:51,207 ERROR [STDERR] at javax.mail.internet.MimeUtility.encodeWord(MimeUtility.java:613) 18:30:51,207 ERROR [STDERR] at javax.mail.internet.MimeUtility.encodeText(MimeUtility.java:444) 18:30:51,207 ERROR [STDERR] at javax.mail.internet.MimeMessage.setSubject(MimeMessage.java:793) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.mail.ui.UISubject.encodeChildren(UISubject.java:29) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.mail.ui.UIMessage.encodeChildren(UIMessage.java:167) 18:30:51,207 ERROR [STDERR] at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886) 18:30:51,207 ERROR [STDERR] at com.sun.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:50) 18:30:51,207 ERROR [STDERR] at com.sun.facelets.component.UIRepeat.process(UIRepeat.java:357) 18:30:51,207 ERROR [STDERR] at com.sun.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:617) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer.renderFacelet(FaceletsRenderer.java:207) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer$1.process(FaceletsRenderer.java:161) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer$RenderingContext.run(FaceletsRenderer.java:79) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:170) 18:30:51,207 ERROR [STDERR] at nz.co.selwynequestriancentre.action.mailingList.AsynchronousMailProcessorImpl.scheduleSend(AsynchronousMailProcessorImpl.java:37) 18:30:51,207 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 18:30:51,207 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 18:30:51,207 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 18:30:51,207 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102) 18:30:51,207 ERROR [STDERR] at nz.co.selwynequestriancentre.action.mailingList.AsynchronousMailProcessorImpl_$$_javassist_11.scheduleSend(AsynchronousMailProcessorImpl_$$_javassist_11.java) 18:30:51,207 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 18:30:51,207 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 18:30:51,207 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 18:30:51,207 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45) 18:30:51,207 ERROR [STDERR] at org.jboss.seam.async.ThreadPoolDispatcher$RunnableAsynchronous.run(ThreadPoolDispatcher.java:126) 18:30:51,207 ERROR [STDERR] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 18:30:51,207 ERROR [STDERR] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 18:30:51,207 ERROR [STDERR] at java.util.concurrent.FutureTask.run(FutureTask.java:138) 18:30:51,207 ERROR [STDERR] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) 18:30:51,207 ERROR [STDERR] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207) 18:30:51,207 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) 18:30:51,207 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) 18:30:51,207 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619) 18:30:51,207 INFO [AsynchronousMailProcessorImpl] < scheduleSend
Bean that calls the Aynch one:
@TransactionAttribute(TransactionAttributeType.REQUIRED) @End public String sendToMailingList() { try { recipients = new ArrayList<User>(); if (testOnly) { User tony = (User) em.createQuery("from User u where u.email = :email").setParameter("email", "tony.herstell@selwynequestriancentre.co.nz").getSingleResult(); recipients.add(tony); } else { MailingListBuilder mailingListBuilder = new MailingListBuilder(); recipients = mailingListBuilder.getMailingList(em); } //Contexts.getEventContext().set("recipients", recipients); //renderer.render("/WEB-INF/pages/mailingList/mailingListEmailWrapper.xhtml"); asynchronousMailProcessor.scheduleSend(3000, recipients); facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,"mailing_list_emailed_successfully"); log.info("Mailing List Email(s) sent!"); } catch (Exception e) { log.error("Mailing List Email(s) sending failed: "+e); } return "success"; }
and bean that does the sending
package nz.co.selwynequestriancentre.action.mailingList; import java.util.List; import javax.ejb.Remove; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; import nz.co.selwynequestriancentre.model.entity.User; import org.jboss.seam.annotations.AutoCreate; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Logger; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.async.Asynchronous; import org.jboss.seam.annotations.async.Duration; import org.jboss.seam.contexts.Contexts; import org.jboss.seam.faces.Renderer; import org.jboss.seam.log.Log; @Name("asynchronousMailProcessor") @AutoCreate public class AsynchronousMailProcessorImpl implements AsynchronousMailProcessor { /** * Inject and leverage the Seam Logger. */ @Logger private Log log; @Asynchronous public void scheduleSend(@Duration long delay, List<User> recipients) { log.info("> scheduleSend"); try { Contexts.getEventContext().set("recipients", recipients); Renderer.instance().render("/WEB-INF/pages/mailingList/mailingListEmailWrapper.xhtml"); } catch (Exception e) { e.printStackTrace(); } log.info("< scheduleSend"); } @Remove @Destroy @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void destroy() { log.info("> destory"); log.info("< destory"); } }
Any ideas why I get this error when I move to an Asynch mode. Works perfectly ok when not Asynch.