12 Replies Latest reply on Jan 16, 2004 6:14 PM by yxyang

    how to access a remote jboss connection factory using a mana

      Hello,

      I have problems when i try to access remote connection factory using a managed connection pool although i followed the FAQ posted by Adrian.

      Question:

      How do I access a remote jboss connection factory using a managed connection pool.

      Sympton:
      The message is always sent to the local testQueue. But it is expected that the message was sent to the remote testQueue.

      Testing Enviroment:
      (1)Two jboss-3.2.2 servers are runing. One is runing on workstation(is called remote server), the other is runing on notebook(my local server).
      (2)Both runing on redhat 9.0.
      (3)/etc/hosts file are set properly in both machine. The $hostname returns the name which maps to non-loop ip address.
      (4)In both jboss servers, testQueue is preconfigued (coming with the installation).
      (5)Testing program: I modified the EchoBean.java from src/main/org/jboss/chap7/ext1. In this testing case, there are six files:
      (a)EchoBean.java
      (b)Echo.java
      (c)EchoHome.java
      (d)ExClient.java
      (e)ejb-jar.xml
      (f)jboss.xml

      I ran the example client (ExClient) on my notebook against the Echo Bean(deployed in my notebook also) which accesses a remote jboss connection factory (workstation) using a managed connection pool. It is expected that the EchoBean will send the message from the client into remote queue.

      I followed the FAQ posted by adrain (in my notebook server):
      (1)deploy the provider for the remote machine (workstation).
      I did this by adding one definition into jms/jms-ds.xml file in local server (notebook) as following (NOTE:172.16.100.103 is remote server ip – workstation):



      RemoteJMSProvider
      jnp://172.16.100.103:1099

      org.jboss.jms.jndi.JBossMQProvider

      UIL2XAConnectionFactory
      UIL2XAConnectionFactory



      (2)deploy the managed connection factory using this provider:
      I did this by adding <tx-connection-factory> in jms-ds.xml file:
      <tx-connection-factory>

      <jndi-name>RemoteJmsXA</jndi-name>

      <xa-transaction/>

      <adapter-display-name>JMS Adapter</adapter-display-name>

      <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
      <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/RemoteJMSProvider</config-property>

      <security-domain-and-application>RemoteJmsXARealm</security-domain-and-application>

      </tx-connection-factory>

      (3)Finally, configued the user/password in conf/login-config.xml.
      <application-policy name = "RemoteJmsXARealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
      flag = "required">
      <module-option name = "principal">guest</module-option>
      <module-option name = "userName">guest</module-option>
      <module-option name = "password">guest</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=TxCM,name=RemoteJmsXA</module-option>
      </login-module>

      </application-policy>


      The ejb-jar.xml file:


      <?xml version="1.0"?>
      <!DOCTYPE ejb-jar
      PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd"
      >

      <ejb-jar>
      <enterprise-beans>

      <ejb-name>EchoBean</ejb-name>
      org.jboss.chap7.ex1.EchoHome
      org.jboss.chap7.ex1.Echo
      <ejb-class>org.jboss.chap7.ex1.EchoBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <resource-ref>
      <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
      <res-type>javax.jms.QueueConnectionFactory</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      <resource-ref>
      <res-ref-name>jms/Queue</res-ref-name>
      <res-type>javax.jms.Queue</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      </enterprise-beans>
      </ejb-jar>

      jboss.xml file:

      <?xml version="1.0"?>

      <enterprise-beans>

      <ejb-name>EchoBean</ejb-name>
      <resource-ref>
      <res-ref-name>jms/Queue</res-ref-name>
      <resource-name>queue</resource-name>
      </resource-ref>
      <resource-ref>
      <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
      <resource-name>queueconnectionfactory</resource-name>
      </resource-ref>

      </enterprise-beans>
      <resource-managers>
      <resource-manager>
      <res-name>queueconnectionfactory</res-name>
      <res-jndi-name>java:/RemoteJmsXA</res-jndi-name>
      </resource-manager>
      <resource-manager>
      <res-name>queue</res-name>
      <res-jndi-name>jnp://172.16.100.103:1099/queue/testQueue</res-jndi-name>
      </resource-manager>
      </resource-managers>




      Thanks very much!

      yang

        • 1. Re: how to access a remote jboss connection factory using a

          If i remove the configuration of the testQueue in local server, i got the following error.
          In addition, when i run the client, the local server does connect to the remote server because i confirmed this by capturing networking traffic (for both cases).

          2004-01-15 17:10:07,301 ERROR [org.jboss.mq.il.uil2.SocketManager] Failed to handle: org.jboss.mq.il.uil2.msgs.TransactMsg1933963099[msgType: m_transact, msgID: -2147483640, error: null]
          org.jboss.mq.SpyTransactionRolledBackException: Transaction was rolled back.; - nested throwable: (javax.jms.InvalidDestinationException: This destination does not exist! QUEUE.testQueue)
          at org.jboss.mq.server.JMSDestinationManager.transact(JMSDestinationManager.java:452)
          at org.jboss.mq.server.JMSServerInterceptorSupport.transact(JMSServerInterceptorSupport.java:186)
          at org.jboss.mq.server.TracingInterceptor.transact(TracingInterceptor.java:438)
          at org.jboss.mq.server.JMSServerInvoker.transact(JMSServerInvoker.java:186)
          at org.jboss.mq.il.uil2.ServerSocketManagerHandler.handleMsg(ServerSocketManagerHandler.java:166)
          at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:355)
          at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:377)
          at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:732)
          at java.lang.Thread.run(Thread.java:568)
          Caused by: javax.jms.InvalidDestinationException: This destination does not exist! QUEUE.testQueue
          at org.jboss.mq.server.JMSDestinationManager.addMessage(JMSDestinationManager.java:399)
          at org.jboss.mq.server.JMSDestinationManager.transact(JMSDestinationManager.java:433)
          ... 8 more


          EchoBean.java:


          public String echo(String arg) throws EJBException
          {
          log.debug("echo, arg="+arg);
          try
          {
          InitialContext iniCtx = new InitialContext();
          Context enc = (Context) iniCtx.lookup("java:comp/env");
          Object ref = enc.lookup("jms/QueueConnectionFactory");
          log.debug("echo, jms/QueueConnectionFactory="+ref);
          QueueConnectionFactory qcf = (QueueConnectionFactory) ref;
          log.info("echo, found qcf="+qcf);
          QueueConnection qc = qcf.createQueueConnection();
          log.info("echo, lookup qc="+qc);
          QueueSession session = qc.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
          log.info("echo, lookup session="+session);
          Queue queue = (Queue)enc.lookup("jms/Queue");
          log.info("echo, lookup queue="+queue);
          QueueSender sender = session.createSender(queue);
          log.info("echo, lookup sender="+sender);
          TextMessage message = session.createTextMessage();
          message.setText(arg);
          sender.send(message);
          session.close();
          qc.close();
          }
          catch(Exception e)
          {
          log.error("Failed during JNDI access", e);
          throw new EJBException();
          }
          return arg;
          }

          • 2. Re: how to access a remote jboss connection factory using a

            You know the xml is not displayed correctly in the faq.
            Use View/Source in your browser to see the full sql and ignore the  

            Regards,
            Adrian

            • 3. Re: how to access a remote jboss connection factory using a

              Also, your test code is incorrect.
              You must guarantee you close the connection/session to return it to the pool.
              e.g.

              Connection c = connectionFactory.createConnection();
              try
              {
              ....
              }
              finally
              {
              c.close();
              }

              Regards,
              Adrian

              • 4. Re: how to access a remote jboss connection factory using a

                andian,

                thanks for your information. But I double checked the xml in my configurations. It has no problem. In this topic, the xml segment i posted also cannot be displayed properly.

                I have a few things (i don't understand fully)
                (1) Are all these configurations only related to local server? I didn't make any changes on remote server. (i.e., jms-ds.xml, login-config.xml)
                (2)in the deploy/jms/ directory, there is only one .ra file, i unjared this file and i found such as line in its ra descriptor file:
                <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:DefaultJMSProvider </config-property>
                Will this introduce problem? I don't know how the config-property specified in jms-ds.xml file overwrite the value in this ra descriptor file?
                (3)Would you mind do a simple explain about the work flow on these configuration files? especially the usage of the jndi names in these files.

                Regards

                yang

                • 5. Re: how to access a remote jboss connection factory using a

                  hi, adrian

                  I found one difference. I forget the "server" attribute of the mbean. What is its function? What is its value? domain name or ip address? I will try tomorrow morning. I hope it will work. Thanks for your FAQ.






                  regards
                  yang

                  • 6. Re: how to access a remote jboss connection factory using a

                    The server attribute is irrelvent. I only added it to make a unique name in case you
                    want to configure two remote jms pools.

                    The rar deployment configurations are just defaults. You override them with your
                    configuration.

                    There is no configuration required on the remote server.

                    It works as follows:

                    You deploy the JMSProvider MBean which contains the JNDI config for the
                    remote machine: jnp://whatever:1099 and UIL2XAConnectionFactory.
                    This configuration object is bound into jndi using the provider name
                    java:/WhateverJMSProvider

                    Then you deploy the connection factory that uses the provider. This instantiates
                    it from the jms rar. You specifiy the JMS provider jndi from before
                    and bind the connection factory at java:/WhateverJmsXA locally.

                    Finally you have to setup the realm so the connection factory knows what
                    user/password to login as when you don't provide a user/password.

                    Regards,
                    Adrian

                    • 7. Re: how to access a remote jboss connection factory using a

                      Hi, Adrian

                      strange! I did have the same configurations. What is the potential problem? Did you ever try your configurations?

                      How to attatch file in this forum?


                      ------------------------------Following is my configuration--------------------

                      < mbean code="org.jboss.jms.jndi.JMSProviderLoader"
                      name="jboss.mq:service=JMSProviderLoader,name=RemoteJBossMQProvider" >
                      < attribute name="ProviderName" >RemoteJMSProvider< / attribute >
                      < attribute name="ProviderUrl" >jnp://172.16.100.103:1099< / attribute >
                      < attribute name="ProviderAdapterClass" >
                      org.jboss.jms.jndi.JBossMQProvider
                      < / attribute >
                      < attribute name="QueueFactoryRef" >UIL2XAConnectionFactory< / attribute >
                      < attribute name="TopicFactoryRef" >UIL2XAConnectionFactory< / attribute >
                      < / mbean >



                      < tx-connection-factory >
                      < jndi-name >RemoteJmsXA< /jndi-name >
                      < xa-transaction/ >
                      < adapter-display-name >JMS Adapter< /adapter-display-name >
                      < config-property name="SessionDefaultType" type="java.lang.String" >javax.jms.Topic< /config-property >
                      < config-property name="JmsProviderAdapterJNDI" type="java.lang.String" >java:/RemoteJMSProvider< /config-property >
                      < security-domain-and-application >RemoteJmsXARealm< /security-domain-and-application >
                      < / tx-connection-factory >


                      < application-policy name = "RemoteJmsXARealm" >
                      < authentication >
                      < login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
                      flag = "required" >
                      < module-option name = "principal" >guest< /module-option >
                      < module-option name = "userName" >guest< /module-option >
                      < module-option name = "password" >guest< /module-option >
                      < module-option name="managedConnectionFactoryName" >jboss.jca:service=TxCM,name=RemoteJmsXA< /module-option >
                      < /login-module >
                      < /authentication >
                      < /application-policy >

                      -------------- AdrianÂ’s configurations ---------------------------------------------------------------

                      < mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=RemoteMQProvider,server=Whatever" >
                      < attribute name="ProviderName" >WhateverJMSProvider< / attribute >
                      < attribute name="ProviderUrl" >jnp://whatever:1099< / attribute >
                      < attribute name="ProviderAdapterClass" >
                      org.jboss.jms.jndi.JBossMQProvider
                      < / attribute >
                      < attribute name="QueueFactoryRef" >UIL2XAConnectionFactory< / attribute >
                      < attribute name="TopicFactoryRef" >UIL2XAConnectionFactory< / attribute >
                      < /mbean >

                      < connection-factories >
                      < tx-connection-factory >
                      < jndi-name >WhateverJmsXA < /jndi-name >
                      < xa-transaction/ >
                      < adapter-display-name >JMS Adapter < /adapter-display-name >
                      < config-property name="SessionDefaultType" type="java.lang.String" >javax.jms.Topic < /config-property >
                      < config-property name="JmsProviderAdapterJNDI" type="java.lang.String" >java:/WhateverJMSProvider < /config-property >
                      < security-domain-and-application >WhateverJmsXARealm < /security-domain-and-application >
                      < /tx-connection-factory >
                      < /connection-factories >




                      NOTE: The name in the managed connection factory reference is the jndi name.

                      < application-policy name = "WhateverJmsXARealm" >
                      < authentication >
                      < login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
                      flag = "required" >
                      < module-option name = "principal" >guest < /module-option >
                      < module-option name = "userName" >guest < /module-option >
                      < module-option name = "password" >guest < /module-option >
                      < module-option name = "managedConnectionFactoryName" >jboss.jca:service=TxCM,name=WhateverJmsXA < /module-option >
                      < /login-module >
                      < /authentication >
                      < /application-policy >


                      regards

                      yang

                      • 8. Re: how to access a remote jboss connection factory using a

                        Are you sure you are connecting to the correct server.
                        Which server shows the error (not from the client stack trace).

                        You've probably hit the /etc/hosts problem, see the FAQ Forum
                        "Cannot connect to localhost" or something like that.

                        Regards,
                        Adrian

                        • 9. Re: how to access a remote jboss connection factory using a

                          Adrian,

                          Thanks for your active response. :) I think this is more than the beauty of the open source. Another question: is my jboss.xml configuration about the remote queue is correct?
                          (especially "<res-jndi-name>jnp://172.16.100.103:1099/queue/testQueue</res-jndi-name>").

                          </enterprise-beans>
                          <resource-managers>
                          <resource-manager>
                          <res-name>queueconnectionfactory</res-name>
                          <res-jndi-name>java:/RemoteJmsXA</res-jndi-name>
                          </resource-manager>
                          <resource-manager>
                          <res-name>queue</res-name>
                          <res-jndi-name>jnp://172.16.100.103:1099/queue/testQueue</res-jndi-name>
                          </resource-manager>
                          </resource-managers>


                          I will try to make sure i connected to the correct server today.

                          thanks very much
                          yang

                          • 10. Re: how to access a remote jboss connection factory using a

                            hi, adrian

                            I solved this problem by upgrading to jboss-3.2.3 after i read the new features/bugs of jboss-3.2.3:

                            JMS

                            * messaging/src/main/org/jboss/mq/server/BasicQueue.java
                            comments: If we expire a message null the local variable so it is not processed. Also fix a potential race between the timed expiration and message addition
                            * messaging/src/main/org/jboss/mq/il/uil/UILServerILService.java, messaging/src/main/org/jboss/mq/il/uil2/UILServerILService.java, messaging/src/main/org/jboss/mq/il/oil2/OIL2ServerILService.java, messaging/src/main/org/jboss/mq/il/oil/OILServerILService.java,
                            comments: Avoid problems where the client can be told to connect to /0.0.0.0. This was introduced in 3.2.2 with the addition of the --host command line argument.
                            * messaging/src/main/org/jboss/mq/SpySession.java
                            comments: Update the message's client id on every send


                            Does this relate to my problem? i suspected the reason is "client can be told to connect to /0.0.0.0.". Why?????

                            Thanks for your discussion

                            yang

                            • 11. Re: how to access a remote jboss connection factory using a

                              I would think if it failed to connect to 0.0.0.0 you would get an error message.
                              Did you set the time-to-live on the message?

                              Regards,
                              Adrian

                              • 12. Re: how to access a remote jboss connection factory using a

                                I don't understand what do you mean "it failed to connect to 0.0.0.0, you would get an error message. Did you set the time-to-live on the message? ". Please give more explaination about this.

                                I didn't set time-to-live on the message.

                                Regards,
                                yang