9 Replies Latest reply on Jul 10, 2003 10:46 PM by roslan

    Autostart application

    alhademic

       

      "alhademic" wrote:
      How to get application automatically started with JBoss launch?

      Application is a java-class with main(String[] args) enry point.


        • 1. Re: Autostart application

          Write an MBean with a start() method.
          To deploy the mbean create a my-service.xml
          like the other -service.xml

          public void start()
          throws Exception
          {
          MyClass.main(args);
          }

          If your main method is blocking, you should
          run it on a background thread to avoid blocking
          the main boot thread.

          Regards,
          Adrian

          • 2. Re: Autostart application
            alhademic

            I've performed all that stuff, but now JBoss server log says:

            [cut]

            2003-06-04 17:32:27,763 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] Failed to deploy:

            org.jboss.deployment.scanner.URLDeploymentScanner$DeployedURL@eacf31b1{

            url=file:/C:/java/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/appointment-service.xml, deployedLastModified=0 }
            org.jboss.deployment.DeploymentException: :service=Appointment is not registered.; - nested throwable:

            (javax.management.InstanceNotFoundException: :service=Appointment is not registered.)
            at org.jboss.deployment.SARDeployer.create(SARDeployer.java:227)
            at org.jboss.deployment.MainDeployer.create(MainDeployer.java:760)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:620)
            at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:585)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

            [cut]

            So the question is: how to register new service?

            • 3. Re: Autostart application

              The most common cause for this error
              is that it cannot find the class of your MBean
              or your MBean class isn't a complaint MBean.

              Try setting the file appender in log4j.xml
              to DEBUG threshold then look in
              server.log.

              Regards,
              Adrian

              • 4. Re: Autostart application
                alhademic

                Ok, you'are right.

                When I fixed this there is more interesting exception appears. My MBean has been extended from ServiceMBeanSupport and implements ServiceMBean interface, but it seems JBoss looks for something else I can't figure out what is this. What can you say?

                The exception is:

                2003-06-05 19:19:25,117 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] Failed to deploy: org.jboss.deployment.scanner.URLDeploymentScanner$DeployedURL@eacf31b1{ url=file:/C:/java/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/appointment-service.xml, deployedLastModified=0 }
                org.jboss.deployment.DeploymentException: Class does not expose a management interface: mail.MailSender; - nested throwable: (javax.management.NotCompliantMBeanException: Class does not expose a management interface: mail.MailSender)
                at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:155)
                at org.jboss.system.ServiceController.install(ServiceController.java:225)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                [cut]

                • 5. Re: Autostart application

                  Post your -service.xml definition

                  Your classes should look something like this

                  public class MyClass
                  extends ServiceMBeanSupport
                  implements MyClassMBean

                  public interface MyClassMBean
                  extends ServiceMBean

                  Regards,
                  Adrian

                  • 6. Re: Autostart application
                    alhademic

                    Ok. Here is the xml-file:

                    <?xml version="1.0" encoding="UTF-8"?>
                    <!DOCTYPE server>








                    ... and the class has been done as you described.

                    • 7. Re: Autostart application

                      implements mail.MailSenderMBean ?

                      Regards,
                      Adrian

                      • 8. Problem closed
                        alhademic

                        There was a problem that interface has been named in other way.

                        I'm surprised that it makes a difference...

                        Now it's ok. :)

                        • 9. Re: Autostart application
                          roslan

                          Hi,
                          In which JAR file is the class ServiceMBeanSupport? I'm following this thread and am trying to implement my own service (autostart class).

                          Also, can you post the complete source for MyClass and MyClassMBean?

                          Thanks,

                          Roslan