Problems with Quartz and the Startup
torhector2 Aug 13, 2009 6:42 PMHy, I'm trying to create a schedule task with Quartz in the startup and it's impossible! I follow other topics, books, Seam documentation and it doesn't work.
I add the code:
package org.domain.meteo.controllers;
import java.util.Calendar;
import java.util.Date;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.async.Asynchronous;
import org.jboss.seam.annotations.async.Expiration;
import org.jboss.seam.annotations.async.FinalExpiration;
import org.jboss.seam.annotations.async.IntervalDuration;
import org.jboss.seam.async.QuartzTriggerHandle;
@Name("iniciador")
@Scope(ScopeType.APPLICATION)
@Startup(depends={"quartzDispatcher"})
public class Iniciador {
        @Observer("org.jboss.seam.postInitialization")
        public void realizarMedidasProgramadas() { 
         
          System.out.println("Enter" );
          
          
          Calendar iCalendar = Calendar.getInstance();
        iCalendar.set(2009, Calendar.AUGUST, 13, 18, 26 );
          
        Calendar fCalendar = Calendar.getInstance();
        fCalendar.set(2009, Calendar.AUGUST, 13, 18, 30 );
          
        
     QuartzTriggerHandle handle = medidasProgramadas(iCalendar.getTime(), 1000l, fCalendar.getTime());
    
     }
     
     @Asynchronous
     public QuartzTriggerHandle medidasProgramadas(@Expiration Date cuando, @IntervalDuration Long intervalo, @FinalExpiration Date fechaFinal ){               
     
               
               System.out.println("TASK" );
               
          return null;
     }
     
     
}
<?xml version="1.0" encoding="UTF-8"?>
<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:mail="http://jboss.com/products/seam/mail"
            xmlns:web="http://jboss.com/products/seam/web"
            xmlns:async="http://jboss.com/products/seam/async"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation=
                "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
                 http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
                 http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
                 http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
                 http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                 http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
                 http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd
                 http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
                 http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.1.xsd" >
   <core:init debug="true" jndi-pattern="@jndiPattern@"/>
   <core:manager concurrent-request-timeout="500"
                 conversation-timeout="120000"
                 conversation-id-parameter="cid"
                 parent-conversation-id-parameter="pid"/>
   <!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
   <web:hot-deploy-filter url-pattern="*.seam"/>
   <persistence:entity-manager-factory name="meteoEntityManagerFactory" 
                           persistence-unit-name="meteo" installed="false"/>
                           
   <persistence:managed-persistence-context name="entityManager"
                           auto-create="true"
                           entity-manager-factory="#{meteoEntityManagerFactory}" 
                           persistence-unit-jndi-name="java:/meteoEntityManagerFactory"/>
   <drools:rule-base name="securityRules">
      <drools:rule-files><value>/security.drl</value></drools:rule-files>
   </drools:rule-base>
   <security:rule-based-permission-resolver security-rules="#{securityRules}"/>
   <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
   <event type="org.jboss.seam.security.notLoggedIn">
      <action execute="#{redirect.captureCurrentView}"/>
   </event>
   <event type="org.jboss.seam.security.loginSuccessful">
      <action execute="#{redirect.returnToCapturedView}"/>
   </event>
   <mail:mail-session host="localhost" port="25"/>
   
 <async:quartz-dispatcher />
   <!-- For use with jBPM pageflow or process management -->
   <!--
   <bpm:jbpm>
      <bpm:process-definitions></bpm:process-definitions>
      <bpm:pageflow-definitions></bpm:pageflow-definitions>
   </bpm:jbpm>
   -->
</components>
Thanks
 
     
     
    