3 Replies Latest reply on Dec 20, 2011 2:58 PM by jcadam14

    Connecting to JBoss ESB 4.9 from deployed JBoss 6 application

    jcadam14

      I have the following code in a deployed application running on JBoss 6.0.0:

       

                Hashtable p = new Hashtable();

                p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

                p.put(Context.PROVIDER_URL, "jnp://XX.XXX.XX.XX:1099"); //ip address of ESB server, which is started with run.bat -b XX.XXX.XX.XX

                p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

                Context context = new InitialContext(p);

                ConnectionFactory factory = (ConnectionFactory) context.lookup("ConnectionFactory");

                conn = factory.createConnection();

                conn.start();

               Session session = conn.createSession(false, 0);

               TextMessage message = session.createTextMessage(schedule.getScheduleData());

               Topic topic = (Topic)context.lookup(VALIDATION_DESTINATION);

               MessageProducer prod = session.createProducer(topic);

               prod.send(message);

       

      The code throws an exception when trying to start the connection.  Here's the stack trace starting at the class that calls conn.start() location:

       

      2011-12-19 10:59:34,198 ERROR [STDERR] (http-155.157.208.50-8080-85) java.lang.NullPointerException
      2011-12-19 10:59:34,198 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.jms.client.container.FailoverValveInterceptor.invoke(FailoverValveInterceptor.java:87)
      2011-12-19 10:59:34,198 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
      2011-12-19 10:59:34,198 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.jms.client.delegate.ClientConnectionDelegate$start_N8025343665958530775.invokeNext(ClientConnectionDelegate$start_N8025343665958530775.java)
      2011-12-19 10:59:34,213 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
      2011-12-19 10:59:34,213 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)
      2011-12-19 10:59:34,213 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.jms.client.delegate.ClientConnectionDelegate$start_N8025343665958530775.invokeNext(ClientConnectionDelegate$start_N8025343665958530775.java)
      2011-12-19 10:59:34,213 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.jms.client.delegate.ClientConnectionDelegate.start(ClientConnectionDelegate.java)
      2011-12-19 10:59:34,213 ERROR [STDERR] (http-155.157.208.50-8080-85)  at org.jboss.jms.client.JBossConnection.start(JBossConnection.java:121)
      2011-12-19 10:59:34,213 ERROR [STDERR] (http-155.157.208.50-8080-85)  at com.rsc.npoess.exportmngr.ValidationService.validateSchedule(ValidationService.java:143)

       

      Is there a trick of trying to connect the two?  I have the javassist.jar, jboss-aop-jdk50-client.jar and jboss-messaging-client.jar in my projects lib directory.  I'm sure I'm just missing some sort of configuration in JBoss 6?  Or can you even mix the two messaging systems?

        • 1. Re: Connecting to JBoss ESB 4.9 from deployed JBoss 6 application
          jcadam14

          Yay progress.  I switched the connection factory name to "java:/XAConnectionFactory" and have been able to I *think* get my connections all right.  However, I now get the following error:

           

          2011-12-19 15:53:54,011 ERROR [STDERR] (http-155.157.208.50-8080-84) javax.jms.InvalidDestinationException: Not a HornetQ Destination:JBossTopic[nativeValidationIn]


          2011-12-19 15:53:54,011 ERROR [STDERR] (http-155.157.208.50-8080-84)  at org.hornetq.jms.client.HornetQSession.createProducer(HornetQSession.java:316)

           

          I put in some print statements for my code (I know, old school but whatever), and I get the following:

           

          2011-12-19 15:53:53,995 INFO  [STDOUT] (http-155.157.208.50-8080-84) Factory: org.hornetq.jms.client.HornetQConnectionFactory@d94838
          2011-12-19 15:53:53,995 INFO  [STDOUT] (http-155.157.208.50-8080-84) Connection: org.hornetq.jms.client.HornetQConnection@18f162c
          2011-12-19 15:53:53,995 INFO  [STDOUT] (http-155.157.208.50-8080-84) Session: HornetQRASession->org.hornetq.core.client.impl.DelegatingSession@17637b5
          2011-12-19 15:53:53,995 INFO  [STDOUT] (http-155.157.208.50-8080-84) Connection started
          2011-12-19 15:53:53,995 INFO  [STDOUT] (http-155.157.208.50-8080-84) TextMessage: HornetQMessage[null]:PERSISTENT
          2011-12-19 15:53:54,011 INFO  [STDOUT] (http-155.157.208.50-8080-84) Topic: JBossTopic[nativeValidationIn]

           

          I have HornetQ jars in my projects lib directory (hornetq-core-client and hornetq-jms-client).  I have a feeling this is causing the disparity between my Connection classes and my Topic class.  Since I'm going from JBoss 6 AS to ESB 4.9, this has to be done, correct?  So it looks like I'm missing a step to get Topic of the right type I guess.  Based on the code above and all this, what direction should I be taking?

           

          Also, does 4.10 correct all this?


          Thanks

           

          • 2. Re: Connecting to JBoss ESB 4.9 from deployed JBoss 6 application
            jcadam14

            I built a bridge between my JBoss 6 AS server and the 4.9 ESB Server.  Here is my configuration:

             

            <bean name="JMSBridge" class="org.hornetq.jms.bridge.impl.JMSBridgeImpl">          
                <depends>HornetQServer</depends>           
                <depends>MBeanServer</depends>
                <constructor>               
                 <!-- Source ConnectionFactory Factory -->               
                 <parameter>                   
                       <inject bean="SourceCFF"/>               
                 </parameter>               
                 <!-- Target ConnectionFactory Factory -->               
                 <parameter>                   
                       <inject bean="TargetCFF"/>               
                 </parameter>               
                 <!-- Source DestinationFactory -->               
                 <parameter>                   
                      <inject bean="SourceDestinationFactory"/>               
                 </parameter>               
                 <!-- Target DestinationFactory -->               
                 <parameter>                   
                       <inject bean="TargetDestinationFactory"/>               
                 </parameter>               
                 <!-- Source User Name (no username here) -->               
                 <parameter><null /></parameter>               
                 <!-- Source Password (no password here)-->               
                 <parameter><null /></parameter>               
                 <!-- Target User Name (no username here)-->               
                 <parameter><null /></parameter>               
                 <!-- Target Password (no password here)-->               
                 <parameter><null /></parameter>               
                 <!-- Selector -->               
                 <parameter><null /></parameter>               
                 <!-- Failure Retry Interval (in ms) -->               
                 <parameter>5000</parameter>               
                 <!-- Max Retries -->               
                 <parameter>10</parameter>               
                 <!-- Quality Of Service -->               
                 <parameter>ONCE_AND_ONLY_ONCE</parameter>               
                 <!-- Max Batch Size -->               
                 <parameter>1</parameter>               
                 <!-- Max Batch Time (-1 means infinite) -->               
                 <parameter>-1</parameter>               
                 <!-- Subscription name (no subscription name here)-->               
                 <parameter><null /></parameter>               
                 <!-- Client ID  (no client ID here)-->               
                 <parameter><null /></parameter>               
                 <!-- Add MessageID In Header -->               
                 <parameter>true</parameter>               
                 <!-- register the JMS Bridge in the AS MBeanServer -->               
                 <parameter>                   
                       <inject bean="MBeanServer"/>               
                </parameter>               
                 <parameter>org.hornetq:service=JMSBridge</parameter>             
              </constructor>           
               <property name="transactionManager">               
                     <inject bean="RealTransactionManager"/>           
               </property>       
               </bean>         
               <!-- SourceCFF describes the ConnectionFactory used to connect to the source destination -->       
               <bean name="SourceCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">           
                <constructor>               
                 <parameter>                   
                  <inject bean="source-JNDI" />               
                               </parameter>               
                 <parameter>JmsXA</parameter>           
                       </constructor>         
               </bean>        
               <!-- TargetCFF describes the ConnectionFactory used to connect to the target destination -->       
               <bean name="TargetCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">           
                <constructor>               
                 <parameter>                   
                       <inject bean="target-JNDI" />               
                 </parameter>               
                 <parameter>ConnectionFactory</parameter>           
               </constructor>         
               </bean>        
               <!-- SourceDestinationFactory describes the Destination used as the source -->       
               <bean name="SourceDestinationFactory" class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">           
                <constructor>               
                 <parameter>                   
                       <inject bean="source-JNDI" />               
                 </parameter>               
              <!-- Source Topic -->
                 <parameter>/topic/ValidateSchedule</parameter>           
                   </constructor>         
               </bean>        
               <!-- TargetDestinationFactory describes the Destination used as the target -->       
               <bean name="TargetDestinationFactory" class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">           
                <constructor>               
                 <parameter>                   
                       <inject bean="target-JNDI" />               
                 </parameter>          
              <!-- ESB destination topic -->     
                 <parameter>/topic/nativeValidationIn</parameter>           
               </constructor>         
               </bean>       
               <!-- Hashtable containing the JNDI properties required to connect to the source resource -->             
               <bean name="source-JNDI" class="java.util.Hashtable">         
                <constructor class="java.util.Map">            
                 <map class="java.util.Hashtable" keyClass="java.lang.String" valueClass="java.lang.String">               
                  <entry>                  
                        <key>java.naming.factory.initial</key>                  
                        <value>org.jnp.interfaces.NamingContextFactory</value>               
                   </entry>               
                  <entry>                  
                        <key>java.naming.provider.url</key>    
                        <!-- Source JBoss 6 AS Server -->              
                        <value>jnp://155.157.208.50:1099</value>               
                   </entry>               
                   <entry>                  
                        <key>java.naming.factory.url.pkgs</key>                  
                        <value>org.jnp.interfaces</value>               
                   </entry>               
                  <entry>                  
                        <key>jnp.timeout</key>                  
                        <value>5000</value>               
                  </entry>               
                  <entry>                  
                        <key>jnp.sotimeout</key>                  
                        <value>5000</value>               
                   </entry>            
                </map>         
               </constructor>      
               </bean>       
               <!-- Hashtable containing the JNDI properties required to connect to the target resource -->             
               <bean name="target-JNDI" class="java.util.Hashtable">         
                <constructor class="java.util.Map">            
                 <map class="java.util.Hashtable" keyClass="java.lang.String" valueClass="java.lang.String">               
                  <entry>                  
                        <key>java.naming.factory.initial</key>                  
                        <value>org.jnp.interfaces.NamingContextFactory</value>               
                  </entry>               
                  <entry>                  
                        <key>java.naming.provider.url</key>                  
                       <!-- Destination JBoss ESB 4.9 Server -->            
                         <value>jnp://10.79.15.76:1099</value>               
                  </entry>               
                  <entry>                  
                        <key>java.naming.factory.url.pkgs</key>                  
                        <value>org.jnp.interfaces</value>               
                  </entry>               
                  <entry>                  
                        <key>jnp.timeout</key>                  
                        <value>5000</value>               
                  </entry>               
                  <entry>                  
                        <key>jnp.sotimeout</key>                  
                        <value>5000</value>               
                   </entry>            
                 </map>         
                </constructor>      
               </bean>
            

             

            However, I'm getting the following, and the bridge never seems to start.

             

            12:12:34,934 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] HornetQ Serv
            er version 2.1.2.Final (Colmeia, 120) stopped
            12:12:34,965 WARNING [org.hornetq.core.deployers.impl.FileConfigurationParser] A
            IO wasn't located on this platform, it will fall back to using pure Java NIO. If
            your platform is Linux, install LibAIO to enable the AIO journal
            12:12:34,965 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] live server
            is starting..
            12:12:34,965 INFO  [org.hornetq.core.persistence.impl.journal.JournalStorageMana
            ger] Using NIO Journal
            12:12:34,965 WARNING [org.hornetq.core.server.impl.HornetQServerImpl] Security r
            isk! It has been detected that the cluster admin user and password have not been
            changed from the installation default. Please see the HornetQ user guide, clust
            er chapter, for instructions on how to do this.
            12:12:35,059 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] Started
            Netty Acceptor version 3.2.1.Final-r2319 155.157.208.50:5455 for CORE protocol
            12:12:35,059 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] Started
            Netty Acceptor version 3.2.1.Final-r2319 155.157.208.50:5445 for CORE protocol
            12:12:35,059 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] HornetQ Serv
            er version 2.1.2.Final (Colmeia, 120) started
            12:12:35,090 WARN  [org.hornetq.jms.bridge.impl.JMSBridgeImpl] Failed to start b
            ridge
            12:12:35,090 WARN  [org.hornetq.jms.bridge.impl.JMSBridgeImpl] Will retry after
            a pause of 5000 ms
            12:12:40,098 INFO  [org.hornetq.jms.bridge.impl.JMSBridgeImpl] Failed to set up
            JMS bridge connections. Most probably the source or target servers are unavailab
            le. Will retry after a pause of 5000 ms (this repeats over and over)

             

            I have no issues pinging the ESB server, I can get to the admin console, I even have a small client class that connects to it, so I know there's no network issues.  Am I missing a configuration in my bridge beans?  I added the jms-messaging.jar to common/lib, and I would think if there was a jar issue I would at least get some error.

             

            Any help is appreciated.

             

            Thanks!

            • 3. Re: Connecting to JBoss ESB 4.9 from deployed JBoss 6 application
              jcadam14

              Oh, if I replace the connection factory names with /ConnectionFactory, /XAConnectionFactory, the same names without slashes, java:/JmsXA, etc it still doesn't connect.  In other words, I've tried any combination I can think of and still no connections.