Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
10. Sep 2008, 20:53 CET | Link

Hello All,
I am using seam for a while now. i have ran into problems in the past but was able to figure out myself with the help of past discussions. I ran into this quartz problem that i am kind of stumped with right now. I have tested this on Jboss and it works great no problem at all. but on glassfish it does not work. below is the code snippet
Here is my enviornment:
Seam 2.0.2SP1
GlassFish V2 ur2

configured quartz on components.xml
<components xmlns="http://jboss.com/products/seam/components"
            xmlns:core="http://jboss.com/products/seam/core"
            xmlns:persistence="http://jboss.com/products/seam/persistence"
            xmlns:drools="http://jboss.com/products/seam/drools"
            xmlns:bpm="http://jboss.com/products/seam/bpm"
            xmlns:security="http://jboss.com/products/seam/security"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:mail="http://jboss.com/products/seam/mail"
            xmlns:async="http://jboss.com/products/seam/async"
            xsi:schemaLocation=
                "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
                 http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
                 http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
                 http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
                 http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                 http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
                 http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
                 http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.0.xsd">

   <core:init debug="@debug@" jndi-pattern="java:comp/env/@jndiPattern@"/>
         <component scope="APPLICATION" auto-create="true" name="renderManager" class="com.icesoft.faces.async.render.RenderManager" />

   <core:manager concurrent-request-timeout="500"
                 conversation-timeout="120000"
                 conversation-id-parameter="cid"
                 parent-conversation-id-parameter="pid"/>
   <!-- this is glassfish specific -->
   <persistence:entity-manager-factory name="xyz" persistence-unit-name="xyz"/>
   <persistence:managed-persistence-context name="entityManager"
                                     auto-create="true"
                                     entity-manager-factory="#{xyz}"/>
   <async:quartz-dispatcher/>
   <mail:mail-session host="xyz" username="xyz" password="xyz" port="25" tls="false"/>
</components>
Interface
@Local
public interface TaskMailProcessor {
           @Asynchronous
    public QuartzTriggerHandle scheduleAlertMailer(@Expiration Date when,
            @IntervalDuration Long interval,
            @FinalExpiration Date endDate) ;
    public void destroy();

}
@Stateful
@Name("taskMailProcessor")
@AutoCreate
public class TaskProcessorImpl implements TaskMailProcessor{
       @In
     EntityManager entityManager;
                @Logger Log log;

     public QuartzTriggerHandle scheduleAlertMailer( Date when,
              Long interval,
              Date endDate)
     {
       List<Tasklist> tasks=entityManager.createQuery("....").getResultList();
       log.info("tasklist size:"+tasks.size());
                if(tasks.size()!=0){
       Contexts.getEventContext().set("emailtasks", tasks);
           Renderer.instance().render("/TaskEmailText.xhtml");
           log.info("Wait you will receive emails");
       }
       else{
       log.info("No task found in next hour");
       }
         return null;
     }
           @Remove
     public void destroy(){
            }
}
@Local
public interface TaskAlertEmail {
        public void observe();
  public void destroy();
  public TaskMailProcessor getTaskMailProcessor();
  public void setTaskMailProcessor(TaskMailProcessor taskMailProcessor);
}
@Stateful
@Name("TaskAlertEmailImpl")
@Scope(ScopeType.APPLICATION)
@Startup
public class TaskAlertEmailImpl implements Serializable,TaskAlertEmail {
    private static final long serialVersionUID = 1881413500711441951L;
              @Logger
    private Log log;
      @In
      private TaskMailProcessor taskMailProcessor;
               /**
   * This is called by seam after initialization
   * has finished.
   */

    @Create
    public void observe() {
            log.info("About to load system properties");
   Calendar cal = Calendar.getInstance ();
      cal.set (2008, Calendar.SEPTEMBER, 20);
         if(taskMailProcessor!=null){
   log.info("goin to send emails");
   QuartzTriggerHandle handle = taskMailProcessor.scheduleAlertMailer(new Date(),1*60*1000L,cal.getTime());
   }
   else
   {
    log.info("Again Null........");
        }
  }


    @Remove
     public void destroy(){
            }

 public TaskMailProcessor getTaskMailProcessor() {
  return taskMailProcessor;
 }

 public void setTaskMailProcessor(TaskMailProcessor taskMailProcessor) {
  this.taskMailProcessor = taskMailProcessor;
 }
}

Few notes Renderer.instance().render("template") causes problem with icefaces. I found a work around for that. So on glassfish the scheduleAlertMailer method is called once the server starts up. But never runs again. But on jboss that method runs every one minute.
My understanding is <async:quartz-dispatcher/> is not registering the quartz sheduler properly on Glassfish. Also i have another context on glassfish server that has quartz configured with a jndi lookup with plain EJB3. I disabled quartz on the context to make sure there was no conflict. no luck. Need some help here. specifically how to register quartz on glassfish with <async:quartz-dispatcher/> or other options to configure quartz
Thanks in advance

5 Replies:
10. Sep 2008, 21:39 CET | Link

Did it throw any kind of error or anything?

 

Best regards,
Joshua

Visit my blog.

10. Sep 2008, 21:43 CET | Link

Nop no errors. Actually it calls the async method one time. but that method never runs again. My understanding is it did not create those recurring job in quartz on startup

10. Sep 2008, 21:45 CET | Link

Also I had to add @EJB private TaskMailProcessor taskMailProcessor; instead of @In to resolve the component on glassfish

11. Sep 2008, 02:45 CET | Link

Funny, could it be because of the location of the quartz library? Perhaps you need to move it to the domain classpath. :-D

 

Best regards,
Joshua

Visit my blog.

22. Sep 2008, 23:16 CET | Link
Tried moving library to domain classpath... dint help.
I just figured out accourding to documentation I need to add
<module>
   <java>quartz-1.6.0.jar</java>
</module>
in application.xml
tried this on too but not working.
Can any one please help me?