2 Replies Latest reply on Aug 17, 2006 10:40 PM by danialdy

    How to start the class when start up the jboss?

    poon wing yee Newbie

      Hi all,
      My system is using jboss. i have the Test.ear in the jboss/server/default/deploy.

      the Test.ear contains some ejb.jar and the Test.war

      when start up the jboss, i will load the run the Test.ear and then create the Ejb.

      Now i need to monitor the time when the deliveryTime is meet, i need to auto send email to the client.

      My idea is create the Thread class to monitor to Time, but i don't know how to start the class.

      How to set the jboss config to start the class.

      anybody can give me suggestion how to do this.

      can jboss set the timer to auto start to check the emailclass directly?

      urgent please help

        • 1. Re: How to start the class when start up the jboss?
          Pat Osterday Newbie

          I think the best way would be to use an MBean to do this. Check out the JBoss docs for MBeans - they are really a great way to do this type of stuff, if I understand your problem correctly.

          Another option is to create a servlet and set it to load on startup - check the docs for web.xml to see this. Hope that helps! Also, MBeans are allowed to create threads and EJBs aren't supposed to create threads according to the spec.

          If you want some cool scheduling type of stuff, check into Quartz - it's great.

          There is also some timer stuff in EJB3, but I haven't done anything with that yet.

          • 2. Re: How to start the class when start up the jboss?
            danialdy Newbie

            I have the best practice:
            From EJB 2.1, there's a timer service. You can create a Timer (can repeat automatically with specified interval time) with it.
            So, you should create an EJB that implements TimedObject, in the method ejbTimeOut, send the email as you want. And you could create a method to start a timer.
            When the JBoss Application Server starts at the first time, the EJB can not be called automatically, create a servlet and set it to load on startup(Just like what osterday said), in the servlet call the EJB's method.
            The auto-startup servlet should be setted to depends on the EJB, then JBoss will load the EJB first.

            Hope helpful!

            Email: duy@routon.com