3 Replies Latest reply on May 14, 2004 12:59 AM by Juha Lindfors

    Running java program within JBoss

    mawa Newbie

      I am writing some java code, which periodically scans a pop3 inbox for messages. When messages are found, an existing session bean should be invoked and some entity bean updates are done.

      The session bean and entity beans are already deployed and working fine.

      My question: How can I run the small java program within jboss ? Is it a component, should it be deployed ? How can it be started during jboss startup ?

      Every answer is welcome.

        • 1. Re: Running java program within JBoss
          Kabir Khan Master

          Never tried this, but you'll want to use the org.jboss.varia.scheduler.Scheduler MBean. The docs contain some stuff aout this

          • 2. Re: Running java program within JBoss
            mawa Newbie

            I just tried it out --- and it works well. Your java class has to implement the Schedulable interface and therefor you have to write a #perform(Date, long) method. After modified the scheduler-service.xml everything is ok. Seems to be easier than writing an own MBean.

            The only problem: The scheduler invokes my code for the first time during his startup, when my EJBs are still not deployed. How can I tell the scheduler to wait until all EJBs are deployed ?

            In scheduler-service.xml there is an attribute , but
            'NOW + 60sec' doesnt work ;-)

            Anyone knows ?

            • 3. Re: Running java program within JBoss
              Juha Lindfors Master

              There are several ways of ordering deployments, all of them covered in the forums many times over, probably most of them also covered in Wiki as well.

              Either set an explicit tag on the EJB container (appears under jboss.j2ee domain, jndiName=XXX, service=EJB) or use a different deployment sorter (e.g. prefix sorter) to order, or create a deploy.last folder for your scheduler service. Search the forums and Wiki for more information.