1 2 Previous Next 16 Replies Latest reply on Apr 7, 2011 2:30 PM by henk de boer

    Unable to validate user?

    henk de boer Master

      I'm using HornetQ on JBoss AS 6. I have defined a simple queue in a file I called my-hornetq-jms.xml inside an EAR and referenced this from jboss-app.xml:

       

       

      <configuration xmlns="urn:hornetq"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
      
        <queue name="myQueue">
            <entry name="/queue/myQueue" />
        </queue>
      
      </configuration>
      
      

       

       

      In a servlet listener in the web module, I tried creating a consumer for this queue as follows:

       

      ConnectionFactory connectionFactory = lookup("java:/ConnectionFactory", ConnectionFactory.class);
      Destination destination = lookup("/queue/myQueue", Destination.class);
           
      connection = connectionFactory.createConnection();  
      connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(destination).setMessageListener(
          new MessageListener() { // rest ommitted
      
      

       

      (lookup is a simple helper function that creates an initial context and does a lookup there)

       

       

      This however results in the following exception message:

       

      HornetQException[errorCode=105 message=Unable to validate user: null for check type CONSUME for address jms.queue.myQueue]
      

       

      If I change the factory to JmsXA is get the following:

       

      HornetQException[errorCode=105 message=Unable to validate user: guest for check type CONSUME for address jms.queue.myQueue]
      

       

      How can I get this to work? Can I add an attribute to the queue definition somehow where I say that I just allow anyone and anything to consume from this queue? I also need to be able to define this in the ear, as I can't touch the JBoss AS 6 instance my ear will be deployed to.

       

       

       


        • 1. Unable to validate user?
          Clebert Suconic Master

          Look at the security settings on the main configuration file.

           

          There's also a section on the user's manual

          • 2. Unable to validate user?
            jaikiran pai Master

            henk de boer wrote:

             

            I'm using HornetQ on JBoss AS 6. I have defined a simple queue in a file I called my-hornetq-jms.xml inside an EAR and referenced this from jboss-app.xml:

            You don't have to add a reference from jboss-app.xml.

             

             

            henk de boer wrote:

             


            In a servlet listener in the web module, I tried creating a consumer for this queue as follows:

            For the rest of the (security related) error messages, my guess is that the servlet listener is being fired before the queue is deployed. I have seen some forum threads where the deployment ordering had lead to this misleading error message. Try setting up a dependency to make sure the queue is deployed before the servlet listener is invoked.

            • 3. Unable to validate user?
              henk de boer Master

              jaikiran pai wrote:

               

              I have defined a simple queue in a file I called my-hornetq-jms.xml inside an EAR and referenced this from jboss-app.xml:

              You don't have to add a reference from jboss-app.xml.

               

              Ok, thanks for the tip. I guess old habits die hard

               

               

              jaikiran pai wrote:

               

              deployed. I have seen some forum threads where the deployment ordering had lead to this misleading error message. Try setting up a dependency to make sure the queue is deployed before the servlet listener is invoked.

               

              That's it! Thanks a bunch! I searched for hours on this but couldn't find it myself.

               

              Now I did immediately run into the next problem and that's that apparently the web module is not allowed to listen to a queue because of some ancient J2EE 1.4(?) rule. I don't really understand the wisdom behind this constraint, but that's another topic.

               

              Anyway, I'm a big step further now. Thanks again.

              • 4. Re: Unable to validate user?
                arjan tijms Novice

                jaikiran pai wrote:


                For the rest of the (security related) error messages, my guess is that the servlet listener is being fired before the queue is deployed.

                What determines this order? I also install a queue consumer in a Servlet listener, but did not see this problem.

                 

                Just to be sure I tried to add the explicit dependency, but what do you need to depend on?

                 

                I tried

                 

                <depends>org.hornetq:module=JMS,name=testQueue</depends>
                

                 

                and

                 

                <depends>org.hornetq:module=JMS,type=Queue,name=testQueue</depends>
                

                 

                in jboss-web.xml, but in both cases the web module doesn't startup at all then. I used the MBean explorer (from Jboss tools) to find these names. Would I need to depend on anything else?

                • 5. Re: Unable to validate user?
                  jaikiran pai Master

                  arjan tijms wrote:

                   

                  jaikiran pai wrote:


                  For the rest of the (security related) error messages, my guess is that the servlet listener is being fired before the queue is deployed.

                  What determines this order? I also install a queue consumer in a Servlet listener, but did not see this problem.

                  Without any explicit dependency (either through configuration or internally through some JBoss AS code), the order is random.

                   

                   

                  arjan tijms wrote:

                   


                   

                  Just to be sure I tried to add the explicit dependency, but what do you need to depend on?

                   

                  I tried ...

                  See this http://community.jboss.org/message/582546#582546

                  • 6. Re: Unable to validate user?
                    arjan tijms Novice

                    jaikiran pai wrote:


                    Without any explicit dependency (either through configuration or internally through some JBoss AS code), the order is random.

                     

                    Is it random for a given structure, or is it random per start-up? E.g. if I deploy an EAR, change nothing but restart JBoss AS a couple of times, can the order then be potentially different with each restart?

                     

                    jaikiran pai wrote:


                    See this http://community.jboss.org/message/582546#582546

                     

                     

                    A double redirect From the linked article:

                     

                     

                    @org.jboss.ejb3.annotation.Depends("org.hornetq:module=JMS,name=\"subbatch\",type=Queue")
                    
                    

                     

                    So I guess in jboss-web.xml this would become:

                     

                    <depends>org.hornetq:module=JMS,name="subbatch",type=Queue</depends>
                    

                     

                    E.g. the quotes around the queue name are absolutely necessary here.

                    • 7. Re: Unable to validate user?
                      jaikiran pai Master

                      arjan tijms wrote:

                       


                      Is it random for a given structure, or is it random per start-up? E.g. if I deploy an EAR, change nothing but restart JBoss AS a couple of times, can the order then be potentially different with each restart?

                       

                      Random per restart. MC has it's own algorithm to push the services to the next state. Without any explicit dependency, the ordering isn't guaranteed across restarts.

                       

                       

                      arjan tijms wrote:

                       

                      jaikiran pai wrote:

                      See this http://community.jboss.org/message/582546#582546

                       

                       

                      A double redirect From the linked article:

                      Oops, I meant to paste the other linked article

                       

                       

                      arjan tijms wrote:

                       


                       

                      @org.jboss.ejb3.annotation.Depends("org.hornetq:module=JMS,name=\"subbatch\",type=Queue")
                      
                      

                       

                      So I guess in jboss-web.xml this would become:

                       

                      <depends>org.hornetq:module=JMS,name=subbatch,type=Queue</depends>
                      

                       

                      E.g. the quotes around the queue name are absolutely necessary here.

                       

                      The double quotes around the value for the name key *are* necessary.

                       

                      So:

                      <depends>org.hornetq:module=JMS,name="subbatch",type=Queue</depends>

                      • 8. Re: Unable to validate user?
                        henk de boer Master

                         

                         

                        jaikiran pai wrote:

                         

                        deployed. I have seen some forum threads where the deployment ordering had lead to this misleading error message. Try setting up a dependency to make sure the queue is deployed before the servlet listener is invoked.

                         

                        That's it! Thanks a bunch! I searched for hours on this but couldn't find it myself.

                         

                        Guess I sheered too soon. The exception is back. Probably it was the random loading order that fixed the problem. Now even with the explicit dependency the problem is back. I added this dependency in jboss-web.xml:

                         

                         

                        <depends>org.hornetq:module=JMS,name="myQueue",type=Queue</depends>
                        

                         

                         

                        I checked whether the dependency worked correctly by changing it into a non existing queue. JBoss AS then correctly complains the queue can't be found. When I change it into the right queue again that error is gone, but the exception about unable to validate the user is back.

                         

                        As a test I created the same listener in a servlet, and then it always works.

                         

                        I probably need to depend on something even later in the deployment pipe-line, but what?

                        • 9. Re: Unable to validate user?
                          henk de boer Master

                          I was running another EAR application on JBoss AS 6, one that has a MDB (in an EJB module) listening to a queue. I just got the following exception during startup:

                           

                           

                          WARN: Failure in HornetQ activation org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@2997e6ad destination=/queue/testQueue destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)
                          HornetQException[errorCode=105 message=Unable to validate user: null for check type CONSUME for address jms.queue.testQueue]
                                    at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:287)
                                    at org.hornetq.core.client.impl.ClientSessionImpl.internalCreateConsumer(ClientSessionImpl.java:1556)
                                    at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:447)
                                    at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:392)
                                    at org.hornetq.core.client.impl.DelegatingSession.createConsumer(DelegatingSession.java:201)
                                    at org.hornetq.ra.inflow.HornetQMessageHandler.setup(HornetQMessageHandler.java:165)
                                    at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:291)
                                    at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:573)
                                    at org.jboss.resource.work.WorkWrapper.run(WorkWrapper.java:172)
                                    at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33)
                                    at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801)
                                    at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45)
                                    at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821)
                                    at java.lang.Thread.run(Thread.java:637)
                                    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
                          
                          

                           

                          After I restarted the server the exception was gone.

                           

                          Could this be another case of HornetQ not being fully initialized before beans and listeners etc are taken into service?

                          • 10. Re: Unable to validate user?
                            henk de boer Master

                            It seems there is now a JIRA issue for this in JBoss AS: https://issues.jboss.org/browse/JBAS-8895

                            • 11. Re: Unable to validate user?
                              Rok Bertoncelj Newbie

                              I'm getting this exception each time I start JBoss if my application is already in the deploy directory. If I first start the server and deploy the application later, when queues have already been deployed, the exception does not occur. Therefore I presume it really is an issue with queues not being fully initialized before MDBs are deployed.

                               

                              Although jaikiran pai mentioned (http://community.jboss.org/message/563234#563234) that

                              if you have a MDB which listens on a queue/topic, then the MDB will not fail if the queue/topic is deployed after the MDB.

                              my MDB did not consume any messages if the exception occured during application startup. I've also checked the MBean for my queue in jmx-console and the ConsumerCount attribute was 0. I've noticed though, that I can restart message delivery trough MBean for my MDB by invoking stopDelivery and startDelivery operations. So the final workaround I've implemented is to check the consumers count and restart delivery at application startup if needed trough MBeanServer. I schedule two "check + restart if needed" cycles, first one occures after MDB is deployed and just in case I check again 5 minutes later.

                               

                              This is the code:

                               

                              public Integer getConsumerCount(String queueName) throws MalformedObjectNameException, InstanceNotFoundException, ReflectionException, AttributeNotFoundException, MBeanException {
                                  Hashtable<String, String> table = new Hashtable<String, String>();
                                  table.put("name", "\"" + queueName + "\"");
                                  table.put("module", "JMS");
                                  table.put("type", "Queue");
                                  ObjectName name = new ObjectName("org.hornetq", table);
                              
                                  MBeanServer server = MBeanServerLocator.locateJBoss();
                                  return (Integer) server.getAttribute(name, "ConsumerCount");
                              }
                              
                              public void restartDelivery(String mdbName, String earFileName, String jarFileName) throws MalformedObjectNameException, InstanceNotFoundException, ReflectionException, MBeanException {
                                  Hashtable<String, String> table = new Hashtable<String, String>();
                                  table.put("service", "EJB3");
                                  table.put("name", mdbName);
                                  table.put("ear", earFileName);
                                  table.put("jar", jarFileName);
                                  ObjectName name = new ObjectName("jboss.j2ee", table);
                              
                                  MBeanServer server = MBeanServerLocator.locateJBoss();
                                  server.invoke(name, "stopDelivery", new Object[0], new String[0]);
                                  server.invoke(name, "startDelivery", new Object[0], new String[0]);
                              }
                              

                               

                               

                              Usage example:

                               

                              Integer consumerCount = null;
                              try {
                                  consumerCount = getConsumerCount("MyQueue");
                              } catch (Exception e) {
                                  log.error("Could not read consumer count, aborting message delivery check.", e);
                                  return;
                              }
                              if (consumerCount > 0) {
                                  log.info("Found " + consumerCount + " consumers. No need to restart message delivery.");
                                  return;
                              }
                              
                              log.info("No consumers found. Restarting delivery.");
                              try {
                                  restartDelivery("MyMdb", "myApp.ear", "myEjb.jar");
                              } catch (Exception e) {
                                  log.error("Could not restart message delivery.", e);
                                  return;
                              }
                              

                               

                               

                              Hope it helps.

                              • 12. Re: Unable to validate user?
                                Clebert Suconic Master

                                We will tight up integration on AS7 (or 6 if still under development/fixes) after we have done the release next week. That's the current plan.

                                • 13. Re: Unable to validate user?
                                  Clebert Suconic Master

                                  We have done some work on QA and we found depdendencies issues on the AS deployers. We will work on it.

                                  • 14. Unable to validate user?
                                    gogoodjob Newbie

                                    This problem does not occur in AS6-CR1. It reappeared in the AS6-Final version

                                    1 2 Previous Next