2 Replies Latest reply on Jul 21, 2004 9:57 AM by ioparra

    Is it possible to have a Startup class for an .ear

      hai.
      i have an web application, for which i need to wirte a startup class. is this possible. is that deploying a .sar file is the only way to accomplish this. kindly help me..
      Thanks in advance
      Senthil Kumar M Rangaswamy

        • 1. Re: Is it possible to have a Startup class for an .ear
          raja05

          startup class for the server? or for the webapp? Why dont u have a InitServlet and load-on-startup?

          • 2. Re: Is it possible to have a Startup class for an .ear
            ioparra

            next to your META-INF/application.xml, create a jboss-app.xml

            add this "type" of entry

            <jboss-app>
             <module>
             <service>startup-service.xml</service>
             </module>
            </jboss-app>
            


            create a startup-service.xml in the root directory of your EAR. this -service.xml is a standard mbean descriptor. Define a customized MBean that does whatever startup you want. During deployment, this mbean will be called and you can do any type of startup you want.

            You may want to keep an eye on deployment ordering and make your mbean depends match your application requirement OR modify your MBean to listen to the startup mechanism

             server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);
             }
            
             public void handleNotification(Notification msg, Object handback)
             {
             if( msg.getType().equals(Server.START_NOTIFICATION_TYPE) )
             {
            


            This didn't work for me on 3.2.1, but works for 3.2.5, you may need to play with this with the different version.

            Good Luck!
            -Ivan