6 Replies Latest reply on Jul 6, 2012 8:29 AM by edojones

    jar client activation

    edojones

      I need to know how to activate jar client application to run into jboss like application-deployment configuration in Oracle 9iAS.

      This jar application implements a TimerTask job which must run once on a day. Its implemented but i can´t make it run.

      In Oracle 9iAS needs to be inluded into the application-deployment.xml file, but i can't find an equivalence into JBoss 3.2.8.

        • 1. Re: jar client activation
          wdfink

          Hi  Eduardo,

          welcome to the forum.

           

          As most of the people here might not know Oracle9iAS (me included) please describe what you want to achieve, maybe attach sources.

          Also you should figure out what EJB version your application use.

           

          As you talk about JBoss 3.2.8 (very old) I suppose it's EJB2.x?

          • 2. Re: jar client activation
            edojones

            I know it's old, but it´s work fine.

            I need to know how can i configure JBoss to execute a jar-client when it´s starts.

            The jar-client has a Timer process that must execute once in a day, at an especific hour.

            In Oracle 9iAS exists a file where you include the applications (ear and/or jar) that must deploy at startup. In JBoss you just need to put de ear file in the deploy directory and it's deployed at startup.

            I've put de jar-client file in the lib directory and it is not activated at startup. Then i put it in the deploy directory and it was deployed, but it did not execute at especific hour.

             

            What i need to do to indicate to JBoss that file must execute?

            • 3. Re: jar client activation
              wdfink

              The schedule timer are available in EJB3.1 (so to new for JBoss3.2)

               

              The old timers are need to be started, then you might have a intervall for it.

              You might use Quarz but I never used it and I'm not sure whether you will have it.

               

              But how your timer code looks like? I think this execution is very 9iAS specific.

              • 4. Re: jar client activation
                edojones

                This is the code

                 

                 

                import cl.ejch.utiles.UtilesFecha;

                import cl.ejch.utiles.UtilesXML;

                 

                import xxx.intAplic.ejb.AdmIntegracionAplicacionesEJBHome;

                import java.sql.Timestamp;

                 

                import java.text.SimpleDateFormat;

                 

                import java.util.Calendar;

                import java.util.Date;

                import java.util.GregorianCalendar;

                import java.util.Timer;

                import java.util.TimerTask;

                 

                import javax.naming.InitialContext;

                 

                import org.w3c.dom.Document;

                 

                public class TraspasoResto  {

                          private Timer timer = new Timer();

                          private Date fechaInicio;

                          private long periodo;

                 

                          public TraspasoResto() {

                                    try  {

                                              Parametros parametros = Parametros.getInstance();

                 

                                              String xmlParamTraspaso = parametros.getXML("procesoTraspasoResto");

                                              System.out.println("xmlParamTraspaso: "+xmlParamTraspaso);

                                              UtilesXML utilesXML = new UtilesXML();

                                              Document docParamTraspaso = utilesXML.XML2Doc(xmlParamTraspaso);

                 

                                              int dias = new Integer(utilesXML.getTagValue(docParamTraspaso, "diasMas")).intValue();

                                              int hora = new Integer(utilesXML.getTagValue(docParamTraspaso, "horaInicio")).intValue();

                                              int minutos = new Integer(utilesXML.getTagValue(docParamTraspaso, "minutoInicio")).intValue();

                                              UtilesFecha utilesFecha = new UtilesFecha();

                                              this.fechaInicio = this.getNuevaFecha(dias, hora, minutos);

                                              System.out.println("this.fechaInicio: "+this.fechaInicio);

                                              this.periodo = new Long(utilesXML.getTagValue(docParamTraspaso, "horas")).longValue() * 60 * 60 * 1000;

                                              System.out.println("this.periodo: "+this.periodo);

                                    } catch (Exception ex)  {

                                              ex.printStackTrace();

                                              System.out.println("TraspasoResto->ex: "+ex);

                                    }

                          }

                 

                 

                  private static Date getNuevaFecha(int _dias, int _hora, int _minutos){

                    Calendar fecha = new GregorianCalendar();

                    fecha.add(Calendar.DATE, _dias);

                    Calendar result = new GregorianCalendar(

                      fecha.get(Calendar.YEAR),

                      fecha.get(Calendar.MONTH),

                      fecha.get(Calendar.DATE),

                      _hora,

                      _minutos

                    );

                    return result.getTime();

                  }

                 

                 

                          public void start(){

                                    timer.scheduleAtFixedRate(new clsTimerTask(), this.fechaInicio, this.periodo);

                          }

                 

                 

                          /**

                           * Clase que realiza el proceso programado de traspaso desde Restô

                           * @since v1.0

                           **/

                          class clsTimerTask extends TimerTask{

                                    public void run(){

                                              UtilesFecha uf = new UtilesFecha();

                                              String xml = "<paramTraspasarComprobante>";

                                              xml += "<fecha>" + new SimpleDateFormat(Parametros.getInstance().getPropiedad("formatoFechaResto")).format(uf.addHorasFechaActual(-24))

                                                        + "</fecha>";

                                              xml += "</paramTraspasarComprobante>";

                                              System.out.println("xml: "+xml);

                 

                 

                                              //Ejecutar Proceso

                 

                                              String mensaje = null;

                                              try  {

                                                        final InitialContext context = new InitialContext();

                                                        AdmIntegracionAplicacionesEJBHome admIntegracionAplicacionesEJBHome =

                                                                  (AdmIntegracionAplicacionesEJBHome)context.lookup("AdmIntegracionAplicacionesEJB");

                 

                 

                                                        mensaje = admIntegracionAplicacionesEJBHome.create().traspasarVentasResto(xml);

                                                        if(mensaje != null && mensaje.length()>0) mensaje = "Datos no pudieron ser procesados. [" + mensaje + "]";

                                                        else mensaje = "Datos procesados";

                                              } catch (Exception ex)  {

                                                        System.out.println("TraspasoResto->clsTimerTask->ex: "+ex);

                                                        mensaje = "Datos no pudieron ser procesados. " + ex.getMessage();

                                              }

                                              System.out.println("mensaje: "+mensaje);

                                    }

                          }

                 

                 

                          public static void main(String[] args)          {

                                    try {

                                              UtilesFecha uf = new UtilesFecha();

                                              System.out.println("TraspasoResto->Inicio Revisión: "+uf.getDate());

                                              TraspasoResto traspasoResto = new TraspasoResto();

                                              traspasoResto.start();

                                              System.out.println("TraspasoResto->Fin Revisión: "+uf.getDate());

                                    }catch (Exception ex)          {

                                              System.out.println("TraspasoResto->ex: "+ex);

                                              ex.printStackTrace();

                                    }

                          }

                }

                • 5. Re: jar client activation
                  wdfink

                  AFAIK there is no chance to get this working as is in JBoss 3.2.

                   

                  The only solution that I know you can find in my last post.

                  • 6. Re: jar client activation
                    edojones

                    Thanks for your answer.

                     

                    I'll try to implemented it with Quartz, but i'd never used it before.