1 Reply Latest reply on Mar 8, 2010 11:15 AM by Dmitry Egorov

    Problem with deployment listener JBoss 5.1

    Dmitry Egorov Newbie

      Hi, everybody!

           I want to make call some business code after my ear deploed or when jboss started.

      I implement sample http://community.jboss.org/wiki/ExampleMinimalNotificationListener override methode handleNotification2()

       

      My deploylistener-service.xml looks like :

      <server>

      <mbean code="my.business.project.NotificationListener" name="rmy.business.project:name=NotificationListener">

      <attribute name="SubscriptionList">

      <subscription-list>

                  <mbean name="jboss.system:type=Server">

                    <notification type="org.jboss.system.server.started"></notification>

                  </mbean>

                  <mbean name="jboss.j2ee:service=EARDeployer">

                    <notification type="org.jboss.deployment.SubDeployer.start"></notification>

                  </mbean>

                  <mbean name="jboss.ejb:service=EJBDeployer">

                    <notification type="org.jboss.deployment.SubDeployer.start"></notification>

                  </mbean>

      </subscription-list>

      </attribute>

      </mbean>

      </server>

       

      But I has troubles:

      1. it seems like notifications from EJBDeployer and EARDeployer don't broadsted, only org.jboss.system.server.started;

      2. To locate my business beans inside methode handleNotification2() i use InitialContext. But when i try,  throws exception javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory

      3. I try make my listener class stateless bean (annotate it @Statless), insert field  bussines bean and use

      @EJB

      private IMyBusinessSessionRemote myBusinessSessionRemote;

       

      But inside handleNotification2()

      myBusinessSessionRemote is not initialized (null);

       

      Please advice:

      1. How can  I access to my business code (to my EJB components) from inside listener

      2. Could anyone give sample about correct  jar and ear deployment listener

        Thanks for any advice.

       

      P.S. Sorry for my poor English.

       

       

      ExampleMinimalNotificationListener

        • 1. Re: Problem with deployment listener JBoss 5.1
          Dmitry Egorov Newbie

          I change code of listener.

              Class annotate with @Service and override start, stop methods (make service).

          When service starting, container call my start() method.

          Inside start()  my ejb myBusinessSession initialized ok, but inside notification2() myBusinessSession == null (method notification2() seems call

          after start()).

          When service stoping, container called stop() method,  inside stop()  myBusinessSession is INITIALIZED again.

                I don't understand container logic, but my task (make some initialization one time on my application deploy) i do inside start().

           

          Thanks for any advise.