7 Replies Latest reply on Jan 17, 2013 3:41 AM by Andrzej Goławski

    Extending JBoss AS 7

    Andrzej Goławski Newbie

      Hi,

      I've recently created a subsystem for my JBoss 7.1.1 using this guide:

       

           https://docs.jboss.org/author/display/AS71/Extending+JBoss+AS+7

       

      Everything works fine, but I'd like to improve TrackerService to be able to sending JMS messages. Is it, somehow,  possible to inject JMS queue to TrackerService class?

       

      I'd be grateful for any help offered!

                Andi

        • 1. Re: Extending JBoss AS 7
          Nicklas Karlsson Master

          Not sure if you can inject it directly but if you make the Messaging subsys a dependecy, at least it should be available for normal lookup, one would think.

          • 2. Re: Extending JBoss AS 7
            Andrzej Goławski Newbie

            Hi Nicklas,

             

            Thank you for your answer. I did as you told and added Messaging dependency:

             

                 <module xmlns="urn:jboss:module:1.0" name="pl.pazp.jboss.aftn">

                                <resources>

                                               <resource-root path="aftn.jar" />

                                               <resource-root path="jboss-jms-api_1.1_spec-1.0.0.Final.jar" />

                          </resources>

             

                                <dependencies>

                                               <module name="javax.api" />

                                               <module name="org.jboss.staxmapper" />

                                               <module name="org.jboss.as.controller" />

                                               <module name="org.jboss.as.server" />

                                               <module name="org.jboss.modules" />

                                               <module name="org.jboss.msc" />

                                               <module name="org.jboss.logging" />

                                               <module name="org.jboss.vfs" />

                                               <module name="org.jboss.as.messaging" />

                                </dependencies>

            </module>

             

            but after that when I tried to lookup for particular queue:

             

                 InitialContext ctx = new InitialContext();

                 Queue queue =  (Queue)ctx.lookup("java:jboss/exported/jms/queue/test");

             

            I received an error:

             

                 java.lang.ClassNotFoundException: javax.jms.Queue

             

            I added jar with JMS API to resources but after that I got:

             

                 javax.jms.Queue can't cast to javax.jms.Queue

             

            I think that is because these two classes have been loaded by diffrent ClassLoaders.

             

            Any idea how to solve it?

            • 3. Re: Extending JBoss AS 7
              Nicklas Karlsson Master

              That's a module dep, I was talking about a subsystem dep

              1 of 1 people found this helpful
              • 4. Re: Extending JBoss AS 7
                Andrzej Goławski Newbie

                Thanks very much for your help!

                You're right, I' ve mixed subsystem with module.

                Unfortunately, I'm not experienced enough in creating subsystems so I have to improve my knowledge in this field. Could you recommend me any source where I can read about defining dependencies between subsystems?

                Best regards! 

                Andi

                • 5. Re: Extending JBoss AS 7
                  Nicklas Karlsson Master

                  Not sure but looking at the web subsystem https://github.com/jbossas/jboss-as/blob/master/web/src/main/java/org/jboss/as/web/WebSubsystemAdd.java there is talk like

                   

                          newControllers.add(target.addService(WebSubsystemServices.JBOSS_WEB, service)

                                  .addDependency(PathManagerService.SERVICE_NAME, PathManager.class, service.getPathManagerInjector())

                                  .addDependency(DependencyType.OPTIONAL, ServiceName.JBOSS.append("mbean", "server"), MBeanServer.class, service.getMbeanServer())

                                  .setInitialMode(Mode.ON_DEMAND)

                                  .install());

                   

                  in the performBoottime

                  • 6. Re: Extending JBoss AS 7
                    Tomaz Cerar Master

                    Andrezj,

                     

                    it is similar to what Nicklas sugessted.

                     

                    When you are working from inside the app server aka extension JNDI is not avalibale to be used.

                    What you have is MSC which handles all the services and is backed by ServiceRegistry.

                    If you are building a service that needs some other service to be injected then the way to do it is what Nicklas posted.

                    You can also do lookup in ServiceRegistery where you can find all service components of app server.

                    Every object that is bound to jndi is backed up by MSC service so it can be injected/lookedup by MSC

                     

                     

                    --

                    tomaz

                    1 of 1 people found this helpful
                    • 7. Re: Extending JBoss AS 7
                      Andrzej Goławski Newbie

                      Thank You very much for your help and suggestions.

                       

                      Andi