1 2 Previous Next 15 Replies Latest reply on Jun 4, 2013 2:19 PM by rharkar

    JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI

    paulh9

      I'm having an issue looking up JMS connections with JNDI within JBOSS. It seems to be a timing issue with the objects are initialized with the Naming Server. I have a couple of JMX beans that try to lookup a ConnectionFactory as they are deployed during JBOSS server startup. For instance this code is executed in my beans start method.

       

                  Context jndiContext = new InitialContext();
                  TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) jndiContext.lookup("XAConnectionFactory");
                  Topic topic = (Topic) jndiContext.lookup(myTopic);

       

      When this is called during JBOSS startup within my JMX Bean start method, the ConnectionFactory is not found. However, the connectionFactory is found if I deploy my bean after the JBOSS server initialization has completed.

       

      I have tried to setup JMX dependencies so that my JMX beans are not deployed until hornet is initialized and this doesn't seem to help.

       

      <depends>jboss.jca:service=ConnectionFactoryBinding,name=JmsXA</depends>

       

      I've also tried doing a delaying the deployment of my beans. Neither of these seem to work.

       

      I've noticed these messages in the boot log and I'm just wondering if they may be related to my issue. It looks like the JNDI initial context is not properly initialized until the end of the boot sequence.

       

      10:02:39,140 INFO  [NamingHelper] JNDI InitialContext properties:{} ...

      10:02:40,200 INFO  [NamingHelper] JNDI InitialContext properties:{}

      10:02:40,181 INFO  [NamingHelper] JNDI InitialContext properties:{}

      10:02:41,040 INFO  [NamingHelper] JNDI InitialContext properties:{}

      10:02:42,187 INFO  [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}

       

      Does anyone know what the issue might be?

       

      thanks,

      Paul

        • 1. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
          jithu.mada

          Maybe you can try implementing JNDI event listeners.

          • 2. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
            paulh9

            Well, I guess I could do that. But my application is started when it is deployed, the JMS service needs to be available when my application is deployed.  So what I'm really looking for is an answer why JMS ConnectionFactories are not available through JNDI when my application is deployed at JBOSS server startup time. These services should be already initialized but it seems that something is not quite right. I'm new to JBOSS, but it seems to me that there is something wrong.

            • 3. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
              shelly.mcgowan

              Can you enable DEBUG logging when booting AS server (passing  -Djboss.boot.server.log.level=DEBUG)?  Provide relevant info here.

              • 4. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                paulh9

                Okay, I enabled DEBUG logging and I see that hornetQ is deploying the ConnectionFactories, queues and topics at the very end of the boot sequence. This is well after my beans are deployed. ....

                 

                14:11:20,128 DEBUG [MCJavaEEApplication] Installed context org.jnp.interfaces.NamingContext@1bd9c75 for JavaEE application disc_oid.proper
                14:11:20,128 DEBUG [MCJavaEEApplication] Installed context org.jnp.interfaces.NamingContext@1fdc01b for JavaEE application hornetq-configuration
                14:11:20,143 DEBUG [HornetQQueueDeployment] Deploying Queue DLQ
                14:11:20,159 DEBUG [HornetQConnectionFactoryDeployment] Deploying ConnectionFactory NettyConnectionFactory
                14:11:20,175 DEBUG [MCJavaEEApplication] Installed context org.jnp.interfaces.NamingContext@102ae46 for JavaEE application hornetq-jms
                14:11:20,175 DEBUG [HornetQTopicDeployment] Deploying Topic rmaAlarmsTopic
                14:11:20,190 DEBUG [HornetQConnectionFactoryDeployment] Deploying ConnectionFactory NettyThroughputConnectionFactory
                14:11:20,190 DEBUG [HornetQConnectionFactoryDeployment] Deploying ConnectionFactory InVMConnectionFactory
                14:11:20,190 DEBUG [HornetQQueueDeployment] Deploying Queue ExpiryQueue
                14:11:20,206 INFO  [service] Removing bootstrap log handlers

                 

                Is this intentionally done with way? Is there a way I can have my bean depend on this deployment?

                 

                thanks,

                Paul

                • 5. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                  shelly.mcgowan

                  To rule out configuration issues, refer to the HornetQ documentation available from the JBoss AS Docmentation Page.

                  • 6. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                    paulh9

                    Thanks Shelly,

                     

                    I think the configuration is okay. I run JBOSS 6 without any of my applications deployed and it still deploys the HornetQ JMS ConnectionFactories last. I'd like to know if there is a way to make a dependency on these conections so my application wouldn't be deployed until the services are ready to go. I'm in the process of migrating from JBOSS 4 to 6 and I'm using JMX Beans xml to do dependencys (see below). But I don't know how to configure a dependency for JNDI JMS resources.

                     

                            <depends>jboss.jca:service=DataSourceBinding,name=PostgresDS</depends>
                            <depends>jboss.jca:service=ConnectionFactoryBinding,name=JmsXA</depends>

                     

                    thanks,

                    Paul

                    • 7. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                      smarlow

                      As a test, try to start the server without your application in the deploy folder.  Then copy your application into deploy and see if you get better results.

                      • 8. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                        paulh9

                        Yes, I've done that and my application is able to lookup the JMS objects. The problem is really timing. I really need to deploy my application when JBOSS starts.

                         

                        Paul

                        • 9. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                          jaikiran

                          Try adding a <depends> on either of the following connection factory MBeans:

                           

                          <depends>org.hornetq:module=JMS,name="InVMConnectionFactory",type=ConnectionFactory</depends>
                          

                           

                           

                          <depends>org.hornetq:module=JMS,name="NettyConnectionFactory",type=ConnectionFactory</depends>

                           

                           

                          <depends>org.hornetq:module=JMS,name="NettyThroughputConnectionFactory",type=ConnectionFactory</depends>
                          • 10. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                            paulh9

                            Hi Jaikiran,

                             

                            I tried your suggestion using the <depends> in my mbean _service.xml. However I get the following error(s)

                             

                            Deployment "org.hornetq:module=JMS,name=NettyThroughputConnectionFactory,type=ConnectionFactory" is in error due to the following reason(s): ** NOT FOUND Depends on 'org.hornetq:module=JMS,name=NettyThroughputConnectionFactory,type=ConnectionFactory' **
                              Deployment "org.hornetq:module=JMS,name=NettyConnectionFactory,type=ConnectionFactory" is in error due to the following reason(s): ** NOT FOUND Depends on 'org.hornetq:module=JMS,name=NettyConnectionFactory,type=ConnectionFactory' **
                              Deployment "org.hornetq:module=JMS,name=InVMConnectionFactory,type=ConnectionFactory" is in error due to the following reason(s): ** NOT FOUND Depends on 'org.hornetq:module=JMS,name=InVMConnectionFactory,type=ConnectionFactory' **

                             

                            -Paul

                            • 11. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                              jaikiran

                              That's strange, because I see those MBeans in the jmx-console. Have you changed anything in the server installation or is this a clean install? What does the JBOSS_HOME/server/<servername>/deploy/hornetq/hornetq-jms.xml look like? And do you see those MBeans in your jmx-console?

                              • 12. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                                paulh9

                                Yes it is strange. I also see those MBeans in the jmx-console. I haven't modifed the hornetq-jms.xml. I'm wondering if it has to so with my mbean definition. Here's it is...

                                 

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

                                <server>
                                    <classpath codebase="./deploy/harris-rma/" archives="BeOnNetMan.jar" />
                                    <classpath codebase="./deploy/harris-rma/"/>
                                    <mbean code="com.harris.rf.beon.alarms.eventlog.EventLogManager"
                                           name="BeOnNetworkManager:service=BeOnEventLog"
                                           xmbean-dd="">
                                        <xmbean>
                                            <attribute access="read-only" getMethod="getEventCount">
                                                <name>Total Logged Events</name>
                                                <type>int</type>
                                            </attribute>
                                            <operation>
                                                <description>Get Most Recent Events</description>
                                                <name>getMostRecentEvents</name>
                                                <parameter>
                                                    <description>count to retrieve</description>
                                                    <name>count</name>
                                                    <type>int</type>
                                                </parameter>
                                                <return-type>java.lang.String</return-type>
                                            </operation>
                                            <operation>
                                                <description>Standard MBean lifecycle method</description>
                                                <name>create</name>
                                            </operation>
                                            <operation>
                                                <description>The start lifecycle operation</description>
                                                <name>start</name>
                                            </operation>
                                            <operation>
                                                <description>The stop lifecycle operation</description>
                                                <name>stop</name>
                                            </operation>
                                            <operation>
                                                <description>The destroy lifecycle operation</description>
                                                <name>destroy</name>
                                            </operation>
                                        </xmbean>

                                        <!-- depends>org.hornetq:module=JMS,name=InVMConnectionFactory,type=ConnectionFactory</depends -->
                                        <depends>org.hornetq:module=JMS,name=NettyConnectionFactory,type=ConnectionFactory</depends>
                                        <!-- depends>org.hornetq:module=JMS,name=NettyThroughputConnectionFactory,type=ConnectionFactory</depends -->
                                        <depends>jboss.jca:service=DataSourceBinding,name=PostgresDS</depends>
                                        <depends>jboss.jca:service=ConnectionFactoryBinding,name=JmsXA</depends>
                                    </mbean>
                                </server>

                                • 13. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                                  jaikiran

                                  Just found out what the problem was. I had a typo in that post where I showed you the dependencies. The correct dependencies are:

                                   

                                  <depends>org.hornetq:module=JMS,name="NettyConnectionFactory",type=ConnectionFactory</depends>

                                   

                                  <depends>org.hornetq:module=JMS,name="InVMConnectionFactory",type=ConnectionFactory</depends>

                                   

                                  <depends>org.hornetq:module=JMS,name="NettyThroughputConnectionFactory",type=ConnectionFactory</depends>

                                   

                                   

                                  Note the use of double quotes in that name. Give it a try and see if that works.

                                   

                                  [Edit: Crazy horrible editor. Turns out I had posted the correct MBean names, but the double quotes get eaten up by the forum editor if I wrap that text in a XML syntax highlighting block. Removed the syntax highlighting to fix the rendering.]

                                  • 14. Re: JBOSS 6.0.0.CR1 JMS ConnectionFactory lookup with JNDI
                                    paulh9

                                    Thanks Jaikiran.

                                     

                                    This solved the problem!

                                     

                                    Paul

                                    1 2 Previous Next