Hello, I've been trying to send an email inside a method annotated with @Asynchronous in plain tomcat using quartz. The method is called properly and works fine, however, for some reason, the renderer cannot find the facelet template (xhtml). If I send the email in a normal method it works fine. After tracing the code I noticed that the problem occurs at the following code returning null:
| package org.jboss.seam.util; | ... | public class Resources | { | ... | public static URL getResource(String resource, ServletContext servletContext) | { | String stripped = resource.startsWith("/") ? | resource.substring(1) : resource; | | URL url = null; | | if (servletContext!=null) | { | try | { | url = servletContext.getResource(resource); | } | catch (Exception e) {} | } | | if (url==null) | { | url = getResource(resource, stripped); | } | | return url; | } | ... | } | I think that when at tomcat the quartz threads are unable to find the resources but I don't understand why. Following are the configurations, code and stack trace: | @Name("coollectScheduler") | @AutoCreate | @Install(true) | public class CoollectScheduler extends EntityController { | /** | * | */ | private static final long serialVersionUID = 1633034787217471953L; | | private static final String WELCOME_MAIL_TEMPLATE = "/registration/welcome-email.xhtml"; | | @Asynchronous | @Transactional(TransactionPropagationType.REQUIRED) | public QuartzTriggerHandle scheduleWelcomeEmail(@Expiration | Date when, @IntervalDuration | Long interval, int numberOfRetries, User user) { | try { | user = getEntityManager().find(User.class, user.getId()); | Contexts.getEventContext().set("newUser", user); | Contexts.getEventContext().set("numberOfRetries", numberOfRetries); | info("Trying #{newUser.welcomeEmailRetries + 1} of #{numberOfRetries} to send welcome email for the new user: #{newUser.name}"); | render(WELCOME_MAIL_TEMPLATE); | user.welcomeEmailSuccessfullySent(); | user.getQuartzHandle().cancel(); | info("Welcome email was successfully delivered to #{newUser.name} at #{newUser.email}."); | } catch (Exception e) { | e.printStackTrace(); | user.incWelcomeEmailRetries(); | if (user.getWelcomeEmailRetries() >= numberOfRetries ) { | warn("Welcome email was not delivered to #{newUser.name} at #{newUser.email} and the system will not try again."); | try { | user.getQuartzHandle().cancel(); | } catch (SchedulerException swallow) { | error(swallow.getLocalizedMessage()); | } | } | else { | warn("Welcome email was not delivered to #{newUser.name} at #{newUser.email} due to: " | + e.getLocalizedMessage() | + ", the system will try again automatically."); | } | } | getEntityManager().persist(user); | getEntityManager().flush(); | return null; | } | | public static CoollectScheduler instance() { | return (CoollectScheduler) Component | .getInstance(CoollectScheduler.class); | } | | } | components.xhtml | ... | <!-- Install the QuartzDispatcher --> | <async:quartz-dispatcher/> | ... | Stacktrace | java.lang.IllegalArgumentException: resource doesn't exist: /welcome-email.xhtml | at org.jboss.seam.ui.facelet.FaceletsRenderer.resourceURL(FaceletsRenderer.java:184) | at org.jboss.seam.ui.facelet.FaceletsRenderer$1.process(FaceletsRenderer.java:160) | at org.jboss.seam.ui.facelet.FaceletsRenderer$RenderingContext.run(FaceletsRenderer.java:78) | at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:169) | at org.jboss.seam.framework.Controller.render(Controller.java:108) | at br.com.liax.coollect.schedule.CoollectScheduler.scheduleWelcomeEmail(CoollectScheduler.java:42) | 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:585) | at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) | at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31) | at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) | at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31) | at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) | at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38) | at org.jboss.seam.util.Work.workInTransaction(Work.java:40) | at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32) | at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) | at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42) | at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) | at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:50) | at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) | at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106) | at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155) | at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91) | at br.com.liax.coollect.schedule.CoollectScheduler_$$_javassist_5.scheduleWelcomeEmail(CoollectScheduler_$$_javassist_5.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:585) | at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) | at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125) | at org.jboss.seam.async.AsynchronousInvocation.call(AsynchronousInvocation.java:52) | at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76) | at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45) | at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:304) | at org.quartz.core.JobRunShell.run(JobRunShell.java:202) | at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529) | What can I do to render an email inside an asynchronous method in plain tomcat? Thanks in advance, Petterson View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110366#4110366 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110366 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user