[JBoss Seam] - Plain Tomcat + Quartz + Mail work together?
by pettersonfp
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
18 years, 4 months
[Messaging, JMS & JBossMQ] - Property from Properties Service not replace in JMS Bridge d
by jammann
Hi all
I have a strange problem with JBoss 4.0.5 with JBoss Messaging 1.4.0. When I define a JMS bridge, I would like to set the username/password using a property which is set via the Properties Service og JBoss. It does not work as expected, the placeholder is not replaced.
The definition of the bridge looks like (spaces in tags added because I couldn't get the post to render meaningfully :-/)
< mbean code="org.jboss.jms.server.bridge.BridgeService"
name="jboss.messaging:service=Bridge,name=DokumentendienstBridge"
xmbean-dd="xmdesc/Bridge-xmbean.xml">
...
< depends>jboss:type=Service,name=SystemProperties< /depends>
...
< attribute name="TargetUsername">${my.jms.user}< /attribute>
< attribute name="TargetPassword">${my.jms.pw}< /attribute>
...
< /mbean>
Although the properties are defined correctly in the Properties Service (I can use them in other descriptors), they are not replaced in this specific configuration file.
What I've tried so far:
- if I define the properties as "regular" system properties (-Dmy.jms.....), the values are correctly replaced
- if I add a default value (e.g. ${my.jms.pw:defaultpw}, the values are correctly replaced
Any idea what is happening here?
Thanks, Joe
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110355#4110355
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110355
18 years, 4 months
[Messaging, JMS & JBossMQ] - Re: different order between sending and receiving(FIFO)
by garneke
If anyone can help me I would appreciate it.
I have re-run my testing with some jboss server side logging enabled. I have also included some logging to let me know when the receiving Client experiences a timeout on the receive(2000) call. It times out more often that I would expect considering the fact that there is no lack of messages to read, but that could be associated with general house cleaning, etc.
The following is an snippet from my simple client log indicating that right after the client timed out on a receive(2000) call and subsequently paused for .25 of a second before calling receive again it read the wrong message. As you can see the JMS Msg ID: 1-1196727135200779567 was received about 6 messages late...
| 0:12:14 11/4/2007) Correct -- serial:[41553] MsgID:[1-1196727134895779565]
| 0:12:15 11/4/2007) Correct -- serial:[41554] MsgID:[1-1196727135077779566]
| 0:12:17 11/4/2007) (2) Sec TIMEOUT -- Delay .25 Secs, prev:[1-1196727135077779566]
| 0:12:20 11/4/2007) Wrong -- serial:[41556] MsgID:[1-1196727135337779568]
| 0:12:20 11/4/2007) Correct -- serial:[41557] MsgID:[1-1196727135484779569]
| 0:12:20 11/4/2007) Correct -- serial:[41558] MsgID:[1-1196727135686779570]
| 0:12:20 11/4/2007) Correct -- serial:[41559] MsgID:[1-1196727135792779571]
| 0:12:20 11/4/2007) Correct -- serial:[41560] MsgID:[1-1196727136006779572]
| 0:12:20 11/4/2007) Correct -- serial:[41561] MsgID:[1-1196727136131779573]
| 0:12:20 11/4/2007) Wrong -- serial:[41555] MsgID:[1-1196727135200779567]
| 0:12:20 11/4/2007) Wrong -- serial:[41562] MsgID:[1-1196727136262779574]
| 0:12:20 11/4/2007) Correct -- serial:[41563] MsgID:[1-1196727136444779575]
| 0:12:20 11/4/2007) Correct -- serial:[41564] MsgID:[1-1196727136657779576]
| 0:12:20 11/4/2007) Correct -- serial:[41565] MsgID:[1-1196727136778779577]
|
It is important to Note: Although I had quite a few "Timeouts" I did not receive a message in the wrong order after every timeout. However, for each message that was out of order it was ALWAYS directly after a "Timeout" of the receive(2000). I have varied my subsequent delay after a receive() times out ranging from .125 - .5 seconds. Without fixing the problem! Do I need to pause in the order of multiple seconds?
The following is a snippet from the jboss server logs indicated the basic queue activity at the time of the error. It also shows that the message in question was delivered late. However, it shows an interesting "NACK" to its Acknowledgment. The simple client that I use is set to read with Client Acknowledgment and I only ACK successful receives. In other words, I do not have any NACK code on my side. Again, I am using a default installation of 4.2.2GA with the exception that my db is mysql. I have added this log entry as an image because it is so large...
[img]http://www.northstarssoccerclub.com/jboss_error.png[/img]
Thanks In Advance!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110354#4110354
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110354
18 years, 4 months