2 Replies Latest reply on Jan 24, 2014 4:38 AM by mylos78

    JMS 2.0 how to specify user credentials?

    mylos78

      Dear all,

      I'd need to use some capabilities of JMS 2.0 such as Automatic Connection Factory and Queue definition. I have elaborated the following code, which however fails because of Security checks ("Unable to validate user: null"). Is there a way to specify the username and password in JMS 2.0 so that I can use the following code ?

       

      @Stateless

      @JMSConnectionFactoryDefinition(name = "java:/MyConnectionFactory",

      className = "javax.jms.ConnectionFactory")

      @JMSDestinationDefinition(name = "java:jboss/jms/queue/myQueue",

      className = "javax.jms.Queue", interfaceName = "javax.jms.Queue")

      public class ManagerEJB {

       

          

            @Resource(mappedName = "java:jboss/jms/queue/myQueue")

           Queue myQueue;

          

           @Inject

           @JMSConnectionFactory("java:/MyConnectionFactory")

           private JMSContext context;

       

           public void sendMessage(String txt) {

               context.createProducer()

               .send(myQueue, txt);

           }

      }

      Thanks

      Mylos

        • 1. Re: JMS 2.0 how to specify user credentials?
          jmesnil

          Either you can annotate your JMSContext with the credentials:

           

               @Inject

               @JMSConnectionFactory("java:/MyConnectionFactory")

               @JMSPasswordCredential(userName="guest",password="guest")

               private JMSContext context;

           

          or you can pass them to the @JMSConnectionFactoryDefinition:

           

              @JMSConnectionFactoryDefinition(

                  name = "java:/MyConnectionFactory",

                  className = "javax.jms.ConnectionFactory",

                  user = "guest",

                   password = "guest"

             )

          1 of 1 people found this helpful
          • 2. Re: JMS 2.0 how to specify user credentials?
            mylos78

            Thanks a lot Jeff!