1 Reply Latest reply on Nov 27, 2013 10:24 PM by Lap Tran

    MessageDriven does not login the Remote JMS Server

    Lap Tran Newbie

      I have 2 JBOSS 4.2.2 GA servers.

       

      S1 for hosting a JMS topic, the username and password for connecting is required.

      S2: contain my MDB for consuming that topic.

       

      I have this publisher:

      Properties pro = new Properties();
      pro.load(MessageSender.class.getResourceAsStream("/jboss-jndi.properties"));
              
      InitialContext ctx = new InitialContext(pro);
              
      TopicConnectionFactory txfac = (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
      TopicConnection topicConnection = txfac.createTopicConnection("username","password");
      topicConnection.start();
              
      Topic topic = (Topic) ctx.lookup("jms/ATopic");
              
      TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);                       
      TopicPublisher topicPublisher = topicSession.createPublisher(topic);
      topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
              
      TextMessage message1 = topicSession.createTextMessage();
      message1.setText("abc");
      topicPublisher.publish(message1);
      

       

      The jboss-jndi.properties

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://remote_server_ip:1099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory
      jnp.timeout=10000
      jnp.sotimeout=10000
      

       

      It works as my expectation.

       

      To consume the Topic, I have this MDB:

      @MessageDriven
      public class NotificationTopicSubscriber implements MessageListener {
      
          public void onMessage(Message message) {
              // New message      
          }
      }
      }
      

       

      The ejb-jar.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
          version="3.0">
          <enterprise-beans>
              <message-driven>
                  <display-name>Notification Listener</display-name>
                  <ejb-name>NotificationTopicSubscriber</ejb-name>
                  <ejb-class>jms.NotificationTopicSubscriber</ejb-class>
                  <messaging-type>javax.jms.MessageListener</messaging-type>
                  <transaction-type>Container</transaction-type>            
                  <activation-config>
                      <activation-config-property>
                          <activation-config-property-name>destinationType</activation-config-property-name>
                          <activation-config-property-value>javax.jms.Topic</activation-config-property-value>
                      </activation-config-property>
                      <activation-config-property>
                          <activation-config-property-name>destination</activation-config-property-name>
                          <activation-config-property-value>jms/ATopic</activation-config-property-value>
                      </activation-config-property>
                      <activation-config-property>
                          <activation-config-property-name>providerAdapterJNDI</activation-config-property-name>
                          <activation-config-property-value>java:/MyJMSProvider</activation-config-property-value>
                      </activation-config-property>
                      <activation-config-property>
                          <activation-config-property-name>useDLQ</activation-config-property-name>
                          <activation-config-property-value>false</activation-config-property-value>
                      </activation-config-property>
                      <activation-config-property>
                          <activation-config-property-name>user</activation-config-property-name>
                          <activation-config-property-value>username</activation-config-property-value>
                      </activation-config-property>
                      <activation-config-property>
                          <activation-config-property-name>password</activation-config-property-name>
                          <activation-config-property-value>password</activation-config-property-value>
                      </activation-config-property>
                  </activation-config>
              </message-driven>
          </enterprise-beans>    
      </ejb-jar>
      

       

      The login-config.xml

      <application-policy name = "MyJmsXARealm">
         <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=MyJmsXA</module-option>
            </login-module>
         </authentication>
      </application-policy>
      

       

      The my-jms-ds.xml

      <connection-factories>

          <mbean code="org.jboss.jms.jndi.JMSProviderLoader"

              name="jboss.mq:service=JMSProviderLoader,name=MyJMSProvider">

              <attribute name="ProviderName">MyJMSProvider</attribute>

              <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>

       

              <attribute name="FactoryRef">java:/XAConnectionFactory</attribute>

              <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>

              <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>

       

              <attribute name="Properties">

                  java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

                  java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

                  java.naming.provider.url=remote_server_ip:1099  

              </attribute>

          </mbean>

       

          <tx-connection-factory>

              <jndi-name>MyJmsXA</jndi-name>

              <xa-transaction />

              <rar-name>jms-ra.rar</rar-name>

              <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>

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

              <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/MyJMSProvider</config-property>

              <max-pool-size>20</max-pool-size>

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

          </tx-connection-factory>

      </connection-factories>

       

      When I deploy my MDB on JBOSS 4.2.2 GA

       

      I has always received this message:

      16:39:52,423 WARN  [JmsActivation] Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@76612ef6(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@7e350225

      destination=/jms/ATopic isTopic=true tx=true durable=false reconnect=10 provider=java:/MyJMSProvider user=username pass=<not shown> maxMessages=1 minSession=1 maxSession=15 keepAlive=60000 useDLQ=true

      DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=5)

      javax.jms.JMSSecurityException: User: username is NOT authenticated

          at org.jboss.mq.security.SecurityManager.authenticate(SecurityManager.java:230)

          at org.jboss.mq.security.ServerSecurityInterceptor.authenticate(ServerSecurityInterceptor.java:66)

          at org.jboss.mq.server.TracingInterceptor.authenticate(TracingInterceptor.java:613)

          at org.jboss.mq.server.JMSServerInvoker.authenticate(JMSServerInvoker.java:172)

          at org.jboss.mq.il.jvm.JVMServerIL.authenticate(JVMServerIL.java:165)

          at org.jboss.mq.Connection.authenticate(Connection.java:1067)

          at org.jboss.mq.Connection.<init>(Connection.java:252)

          at org.jboss.mq.SpyConnection.<init>(SpyConnection.java:104)

          at org.jboss.mq.SpyConnectionFactory.internalCreateConnection(SpyConnectionFactory.java:167)

          at org.jboss.mq.SpyConnectionFactory.createTopicConnection(SpyConnectionFactory.java:123)

          at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupTopicConnection(JmsActivation.java:526)

          at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupConnection(JmsActivation.java:435)

          at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:317)

          at org.jboss.resource.adapter.jms.inflow.JmsActivation$SetupActivation.run(JmsActivation.java:635)

          at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)

          at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)

          at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)

          at java.lang.Thread.run(Thread.java:662)

       

      Do I have something wrong in my config ?

       

      Thanks.

        • 1. Re: MessageDriven does not login the Remote JMS Server
          Lap Tran Newbie

          Resolved.

           

          The my-jms-ds.xml should be:

           

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

           

              <mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=MyRemote">

                  <attribute name="JndiName">MyRemote</attribute>

                  <attribute name="Properties">

                        java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

                      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

                    

                      java.naming.provider.url=ip_address:1099

                  </attribute>

              </mbean>

            

              <mbean code="org.jboss.jms.jndi.JMSProviderLoader"

                  name="jboss.mq:service=JMSProviderLoader,name=MyJMSProvider">

                  <attribute name="ProviderName">MyJMSProvider</attribute>

                  <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>

           

                  <attribute name="FactoryRef">MyRemote/XAConnectionFactory</attribute>

                  <attribute name="QueueFactoryRef">MyRemote/XAConnectionFactory</attribute>

                  <attribute name="TopicFactoryRef">MyRemote/XAConnectionFactory</attribute>

           

                  <depends>jboss.jndi:service=ExternalContext,jndiName=MyRemote</depends>

              </mbean>

           

          And the The ejb-jar.xml should be:

          <activation-config-property> 

               <activation-config-property-name>destination</activation-config-property-name> 

               <activation-config-property-value>MyRemote/jms/ATopic</activation-config-property-value> 

          </activation-config-property>