1 Reply Latest reply on May 26, 2010 3:42 AM by Galder Zamarreño

    Delay in starting HASingletonDeployer EJB binding

    Prashant B Newbie



      I have written timer using HASingletonDeployer type=Barrier. Below is code for that


      public class GenerationEJBTimer implements IRegenerationTimer {
           * Start the EJB Timer
          public void startTimer() {
              LOGGER.debug("SiteGenerationEJBTimer : START TIMER");    
              // Check if any instances of the Timer already exists. If so kill it!!!
              //timer start code


      and Interface is


      public interface IRegenerationTimer {
          public final static String EJB_JNDI = "ejb/local/RegenerationTimer";
          public static final String TIMER_NAME = "REGENERATION_TIMER";
          public final Long FIVE_MINUTES = 1000L*60L*5L;
           public void startTimer();
          public void stopTimer();

      and I have written servlet listener which will call GenerationEJBTimer through JNDI lookup.



      public class InitializeRegenerationTimer implements ServletContextListener {
          public void contextInitialized(ServletContextEvent aSce) {
              LOGGER.info("Initializing InitializeRegenerationTimerContext : START");   
              try {
              } catch (NamingException e) {
                  LOGGER.error("ERROR: Unable to locate RegenerationEJBTimer...", e);            
              LOGGER.info("Initializing InitializeRegenerationTimerContext : STOP");
          private IRegenerationTimer getRegenerationEJBTimer() throws NamingException
              InitialContext ctx = new InitialContext();        
              return (ISiteRegenerationTimer)ctx.lookup(IRegenerationTimer.EJB_JNDI);


      and this will be declared in web.xml as below



      Now when I deploy this in Jboss 4.2.1.GA cluster server, I am getting javax.naming.NameNotFoundException: ejb not bound at exception even though EJB is deployed before the web app.


      when I looked at the logs EJB is starting before web app starts but binding is happening after web app starts. Because of that InitializeRegenerationTimer.getRegenerationEJBTimer() is throwing ejb not bound at exception error.


      Please help me how to overcome this problem.


      thanks in advance.