1 2 Previous Next 19 Replies Latest reply on Oct 29, 2003 8:51 AM by arabin

    Startup class

    Arvind Newbie

      I do some my application configuration loading at app server startup.I have created an MBean to do this.I used to configure this jboss.jcml in Jboss2.4.6_Tomcat4.0.3 versions.

      Could someone point to about how should achieve this in Jboss3.0.3?

      Thanks.

      Arvind

        • 1. Re: Startup class
          Adrian Brock Master

          server/{config}/conf/jboss-service.xml

          or better is add something to user-service.xml
          in server/{config}/deploy

          Regards,
          Adrian

          • 2. Re: Startup class
            Arvind Newbie

            Adrian,
            Thanks

            I updates the user-service.xml as follows

            <!--
            | Add custom MBeans here. MBeans should be registered under the
            | 'user' JMX domain, or a domain specific to the component application.
            |
            | Do not place user components in the 'jboss' domain or any sub-domain.
            -->

            <!-- Example Service Configuration


            AttributeValue

            -->

            <!-- ==================================================================== -->
            <!-- Startup class - Added by Arvind on 10/04/2002 -->
            <!-- ==================================================================== -->

            JbossStartup
            C:\\WINNT\\halogenapp.ini
            C:\\WINNT\\halogenapp.ini




            What does the following sentence mean

            MBeans should be registered under the
            | 'user' JMX domain, or a domain specific to the component application.

            How do I do register mbean?.Sorry to bother you,asI don't have acces to any form of documenation to findouut these details.

            Thanks,

            Arvind

            • 3. Re: Startup class
              Adrian Brock Master

              The service controller does the registration using
              the name

              user:service=JbossStartup

              you might want to use

              com.sungard:service=JbossStartup

              you could even create a

              sungard-service.xml in server/default/deploy

              Regards,
              Adrian

              • 4. Re: Startup class
                Arvind Newbie

                Adrian,
                When I start Jboss I get this error

                rver/default/deploy/jms-service.xml
                17:53:56,453 INFO [MainDeployer] Starting deployment of package: file:/C:/Java/
                jboss-3.0.3/server/default/deploy/user-service.xml
                17:53:56,623 ERROR [URLDeploymentScanner] Failed to deploy: org.jboss.deployment
                .scanner.URLDeploymentScanner$DeployedURL@8071fb34{ url=file:/C:/Java/jboss-3.0.
                3/server/default/deploy/user-service.xml, deployedLastModified=0 }
                org.jboss.deployment.DeploymentException: com.sungard:service=JbossStartup is no
                t registered.; - nested throwable: (javax.management.InstanceNotFoundException:
                com.sungard:service=JbossStartup is not registered.)
                at org.jboss.deployment.SARDeployer.create(SARDeployer.java:227)
                at org.jboss.deployment.MainDeployer.create(MainDeployer.java:755)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:615)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:580)

                In fact the comments in the user-service.xml says

                <!--
                | Add custom MBeans here. MBeans should be registered under the
                | 'user' JMX domain, or a domain specific to the component application.
                |
                | Do not place user components in the 'jboss' domain or any sub-domain.
                -->


                But I don't know what I have to do.

                I greatly appreciate your patience and help.

                Arvind

                • 5. Re: Startup class
                  Adrian Brock Master

                  This is the second time somebody has reported
                  something like this, the error reporting seems a bit
                  crock.

                  Your JBossStartupClass is deployed in jar somewhere?
                  Your JbossStartupClass is an MBean?
                  If it is a standard mbean, the attributes normally
                  start with uppercase letters.
                  Is there any extra info in server/default/server.log?

                  Regards,
                  Adrian

                  • 6. Re: Startup class
                    Arvind Newbie

                    Adrian,
                    My startup class is deployed as jar in server\deploy\lib directory,and it is a standard MBean.

                    I made some changes to my user-service.xml and my Mbean after having better understanding from your rsponses and also some of the reading I did on MBeans.If you see my code, I am loading some configurations in init() method.Is my understanding that this init() method gets called while registering this Mbean , correct?

                    I am attching interface of MBean,implementaion,user-service.xml,and the error I am getting.I checked log, it contains the same stack trace as is in the attached screen shot.

                    Thanks,

                    Arvind

                    • 7. Re: Startup class
                      Arvind Newbie

                      Adrian,
                      My startup class is deployed as jar in server\deploy\lib directory,and it is a standard MBean.

                      I made some changes to my user-service.xml and my Mbean after having better understanding from your rsponses and also some of the reading I did on MBeans.If you see my code, I am loading some configurations in init() method.Is my understanding that this init() method gets called while registering this Mbean , correct?

                      I am attching interface of MBean,implementaion,user-service.xml,and the error I am getting.I checked log, it contains the same stack trace as is in the attached screen shot.

                      Thanks,

                      Arvind

                      • 8. Re: Startup class
                        Juha Lindfors Master

                        you need to declare your management attributes (that you use in user-service.xml) in your MBean interface class as well

                        • 9. Re: Startup class
                          Arvind Newbie

                          Thanks, it did help.I overlooked that,sorry for the trouble.
                          Is my assumption that init() method I defined in Mbean gets called automatically,correct?.It was true in Jboss-2.4.6_Tomcat-4.0.3.If that is not so in case of Jboss-3.0.3, then how could it be done.My main purpose of this Mbean is to call a application intialization class at server startup time.If you see my code attached in the previous mail , you may see I am calling main method of FrameWorkConfig class.

                          When are the attribute values from user-service.xml get loaded into MBean?.I tried to print the attribute values in MBean constructor, hey are null indicating that they are not loaded when the MBean object is constructed.

                          Thanks

                          Arvind

                          • 10. Re: Startup class
                            Juha Lindfors Master

                            after construction, the MBean needs to be instantiated and registered to the MBean server before setAttribute can be called

                            • 11. Re: Startup class
                              Arvind Newbie

                              I am specifying the MBean in user-service.xml,so I understand the registartion of the MBean should be taken care by Jboss startup,and the attribute values loaded.Is that correct?.In the xml file I am also specifying the attributes.Section of user-service.xml is


                              C:\\WINNT\\halogenapp.ini
                              DEFAULT


                              Thanks.

                              Arvind

                              • 12. Re: Startup class
                                Adrian Brock Master

                                >Is my assumption that init() method I defined in Mbean gets called automatically,correct?.

                                It was changed to create() in jboss3,
                                it better describes what it does.

                                preRegister is for initialization (before attributes
                                are set)

                                If you need it to work in both versions.
                                public void create()
                                {
                                init();
                                }

                                Regards,
                                Adrian

                                • 13. Re: Startup class
                                  Arvind Newbie

                                  Adrian,
                                  I really appreciate you sharing your knowledge.It now works.Thanks a lot for your help.

                                  Arvind.

                                  • 14. Re: Startup class
                                    Mike Pettit Newbie

                                    Hi -
                                    this thread has been very useful. I am trying to do the same thing, but my create() and/or init() methods are not being called automatically. Any clues on that?

                                    Also, I am doing some stuff with my database and my MBean is being loaded before my datasource is bound. doesn't seem to work in my user-service.xml... any clues?

                                    -Mike

                                    1 2 Previous Next