1 Reply Latest reply on Mar 22, 2009 12:29 PM by Daniel Gaiottino

    STARTED Notification delayed until redeploy?

    Daniel Gaiottino Newbie

      Hi,
      I'm running JBoss 4.2.3 and I'm trying to listen to JMX Notifications and have the NotificationListenerMBean example working so that I can actually see notifications being logged.

      My problem is that I only receive the end notification i.e. STARTED or FAILED when I redeploy the app!?! Anyone seen this happen before?

      Here's a dump from my server log.

      17:33:23,939 ERROR [bieg.NotificationListener] $$$START_DEPLOYER: file:/home/daniel/messaging-platform/JBoss423a/server/custom1/deploy/webs/100.test.ear
      17:33:23,945 INFO [org.jboss.deployment.EARDeployer] Started J2EE application: file:/home/daniel/messaging-platform/JBoss423a/server/custom1/deploy/webs/100.test.ear
      


      You can clearly see that I get the START_DEPLOYER Notification but not the STARTED Notification which I would expect since the INFO line says "17:27:30,375 INFO [org.jboss.deployment.EARDeployer] Started J2EE..."

      If I now redeploy the ear.

      17:34:34,032 INFO [org.jboss.web.tomcat.service.TomcatDeployer] undeploy, ctxPath=/mpee, warUrl=.../tmp/deploy/tmp17927100.test.ear-contents/test.war/
      17:34:34,035 INFO [com.telrock.platform.context.listener.ServiceManager] Removing the hibernate stuff from JNDI
      17:34:34,257 ERROR [bieg.NotificationListener] $$$STARTED: file:/home/daniel/messaging-platform/JBoss423a/server/custom1/deploy/webs/100.test.ear
      17:34:34,305 ERROR [bieg.NotificationListener] $$$STOPPED: file:/home/daniel/messaging-platform/JBoss423a/server/custom1/deploy/webs/100.test.ear
      


      And then I start getting the INIT_DEPLOYER Notifications. I've tried this for all the different Deployers (ServiceDeployer, JARDeployer, EARDeployer, EJBDeployer, RARDeployer, WebServer). I never receive the STARTED notification when it has actually started.

      Again, I'm running the sample code and the handleNotification2 is

       public void handleNotification2(Notification notification, Object handback)
       {
       //log.error("Got notification: " + notification + ", handback: " + handback);
      
       DeploymentInfo deploymentInfo = (DeploymentInfo) notification.getUserData();
       log.error("$$$" + deploymentInfo.state + ":\t\t " + deploymentInfo.watch);
       }
      


      Hoping someone has the answer to this.

      Thanks,
      - Daniel

        • 1. Re: STARTED Notification delayed until redeploy?
          Daniel Gaiottino Newbie

          Since I could not find an answer looking through the Forums or the Wiki I resorted to downloading the source code.

          Basically my goal is to be able to receive STARTED and FAILED notifications when an ear has actually started or failed. Currently these notifications are not sent. STARTED is sent once you redeploy the app as I have showed in the previous post, and the FAILED notification isn't sent at all.

          I've been remote debugging the deployers and it seems these are just not sent when you expect them. To solve the problem I've had to modify some of the JBoss code.

          EARDeployer.java

           public void start(DeploymentInfo di) throws DeploymentException
           {
           ...
           log.info("Started J2EE application: " + di.url);
           }
          


          As you can see above, the start method ends with a log.info. This is where I would have expected a STARTED notification to be sent. There is none, and there is none in the ServiceController.start method which is also called by EARDeployer.start.

          I modified the code to be
           public void start(DeploymentInfo di) throws DeploymentException
           {
           ...
           log.info("Started J2EE application: " + di.url);
          
           di.state = DeploymentState.STARTED;
           Notification notification = new Notification(
           di.state.toString(),
           di.deployer.getServiceName(),
           super.nextNotificationSequenceNumber()
           );
           notification.setUserData(di);
           sendNotification(notification);
           }
          


          To receive FAILED notifications, I added code to EARDeployer to 4 methods: init, create, start, stop. Depending on what is wrong with the ear, a deployement can fail in any of these method. All these methods begin with a try/catch so the code is the same for each method.

          Current code
           public void init(DeploymentInfo di) throws DeploymentException
           {
           try
           {
           ...
           } catch (Exception e)
           {
           DeploymentException.rethrowAsDeploymentException("Error in accessing application metadata: ", e);
           }
           ...
           }
          


          Modified to receive FAILED notifications
           public void init(DeploymentInfo di) throws DeploymentException
           {
           try
           {
           ...
           } catch (Exception e)
           {
           di.state = DeploymentState.FAILED;
           Notification notification = new Notification(
           di.state.toString(),
           di.deployer.getServiceName(),
           super.nextNotificationSequenceNumber()
           );
           notification.setUserData(di);
           sendNotification(notification);
          
           DeploymentException.rethrowAsDeploymentException("Error in accessing application metadata: ", e);
           }
           ...
           }
          
          


          The create, start, stop methods are modified similarly to the init method above.

          Unless someone can show me a different way of getting these notifications, I'm going to add my findings to a JIRA ticket since not getting the STARTED and FAILED notifications limits the usefulness of being able to create NotificationListeners.

          I've only been interested in the EARDeployer but the same bug exists for the other deployers such as JARDeployer.