0 Replies Latest reply on Aug 18, 2011 12:52 PM by Florian Stendel

    Unable to validate user: queueUser for check type CONSUME for address jms.queue.RandomQueue

    Florian Stendel Newbie

          Hi there,

       

       

       

         i'm implementing a webservice on JBoss AS 6.0 Final using the native stack.

         The service consists of an (JMS-)Producer, a (JMS-)queue and an  (JMS-)consumer.

       

         The queue is configured as follows:

       

      hornetq-jms.xml

        <connection-factory name="MaxRateNettyConnectionFactory">
            <connectors>
               <connector-ref connector-name="netty"/>
            </connectors>
            <entries>
               <entry name="/MaxRateConnectionFactory"/>
               <entry name="/XAMaxRateConnectionFactory"/>
            </entries>
         </connection-factory>
        <queue name="RandomQueue">
              <entry name="/queue/RandomQueue"/>
         </queue>
      
      

       

       

      hornetq-configuration.xml

       

      ...
         <security-settings>
            <security-setting match="jms.queue.RandomQueue">
               <permission type="createNonDurableQueue" roles="queueUserRole"/>
               <permission type="deleteNonDurableQueue" roles="queueUserRole"/>
               <permission type="consume" roles="queueUserRole"/>
               <permission type="send" roles="queueUserRole"/>
            </security-setting>
         </security-settings>
      
         <address-settings>
            <address-setting match="jms.queue.RandomQueue">
               <redelivery-delay>0</redelivery-delay>
               <max-size-bytes>10485760</max-size-bytes>       
               <message-counter-history-day-limit>10</message-counter-history-day-limit>
               <address-full-policy>BLOCK</address-full-policy>
            </address-setting>
         </address-settings>
      ...
      

       

       

      The role is configured in hornetq-roles.properties :

       

      queueUser=queueUserRole
      

       

      The user is configured in hornetq-users.properties like:

       

      queueUser=queuePassword
      

       

       

      The Producer is created in the ServiceImplementation-Class using the following code:

       

       

      try{
                  Context initial = new InitialContext();
                  ConnectionFactory cf = (ConnectionFactory)initial.lookup("MaxRateConnectionFactory");
                  Destination queue = (Destination)initial.lookup("/queue/RandomQueue");
      
                  Connection connection = cf.createConnection("queueUser","queuePassword");
                  Session session =  connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                  MessageProducer producer =  session.createProducer(queue);
      
      
                  ObjectMessage messageObject = session.createObjectMessage(randomObject);
                  producer.send(messageObject);
      
                  session.close();
                  connection.close();
              }catch(InvalidDestinationException e){
                  logger.error("There is no queue with name '"+QUEUE_JNDI+"' registered.");
              }catch(JMSException e){
                  e.printStackTrace();
              }catch(NamingException e){
                  e.printStackTrace();
              }
          }    
      

       

       

      The consumer is created during initialization of the service through a static-block:

       

       

      static{
              RandomJMSConsumer jmsConsumer = new RandomJMSConsumer();
          }
      

       

      with:

       

       

       public class RandomJMSConsumer implements MessageListener{
      
          final ClassLoader webClassLoader = Thread.currentThread().getContextClassLoader();
          private static final String QUEUE_JNDI = "/queue/RandomQueue";
      
      
          Context context = null;
          MessageConsumer queueConsumer = null;
          Session session = null;
          Connection connection = null;
          Destination queueDestination=null;
      
          public RandomJMSConsumer(){
      
              try {
      
                  context = new InitialContext();
                  ConnectionFactory queueFactory = (ConnectionFactory) context.lookup("MaxRateConnectionFactory");
                  queueDestination = (Destination)context.lookup(QUEUE_JNDI);
      
                  connection = queueFactory.createConnection("queueUser","queuePassword");
      
      
                  session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
                  queueConsumer = session.createConsumer(queueDestination);
      
                  queueConsumer.setMessageListener(this);
                  connection.start();
      
              } catch (NamingException e) {
                  e.printStackTrace();
              } catch (JMSException e) {
                  e.printStackTrace();
              }        
          }
      
      
          @Override
          public void onMessage(Message message) {
      
              ClassLoader oldLoader = null;
      
              try {
      
                  oldLoader = Thread.currentThread().getContextClassLoader();
      
                  Thread.currentThread().setContextClassLoader(webClassLoader);
      
      
                  ObjectMessage oMessage = (ObjectMessage)message;    
                  RandomObject randomObject = (RandomObject)oMessage.getObject();
      
      
                  /** do something **/
                  Thread.sleep(1000);
      
              } catch (JMSException e) {
                  logger.error("JMSException in RandomJMSConsumer. Message was:"+e.getMessage(),e);
              } catch (InterruptedException e) {
                  logger.error("InterruptedException in RandomlJMSConsumer. Message was:"+e.getMessage(),e);
              } 
              finally {
                  if (oldLoader != null) {
                      Thread.currentThread().setContextClassLoader(oldLoader);
                  }
              }
      
          }
      
      
      
          /**
           * Allows to deregister 
           * 
           */
          public void unregister(){
              logger.info("unregister JMSConsumer");
              try{ 
                  if(null!= queueConsumer)
                      queueConsumer.close();
              }catch(JMSException e){
                  e.printStackTrace();
              }
              try{ 
                  if(null!= session)
                      session.close();
              }catch(JMSException e){
                  e.printStackTrace();
              }
              try{ 
                  if(null!= connection)
                      connection.close();
              }catch(JMSException e){
                  e.printStackTrace();
              }
              try{ 
                  if(null!= context)
                      context.close();
              }catch(NamingException e){
                  e.printStackTrace();
              }
          }
      }
      

       

       

      The unregister method is called from an annotated (@Predestroy) cleanUp-Method to asure, there aren't multiple consumers deployed on redeployment of the service.

       

       

       

       

      The problem i've got is this:

       

      When i restart the server i got the following Stacktrace, while the service is initializing:

       

      javax.jms.JMSSecurityException: Unable to validate user: queueUser for check type CONSUME for address jms.queue.RandomQueue
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:287)
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientSessionImpl.internalCreateConsumer(ClientSessionImpl.java:1556)
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:447)
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:413)
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.core.client.impl.DelegatingSession.createConsumer(DelegatingSession.java:187)
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.jms.client.HornetQSession.createConsumer(HornetQSession.java:531)
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.jms.client.HornetQSession.createConsumer(HornetQSession.java:375)
      
      14:40:03,390 ERROR [STDERR]     at org.hornetq.jms.client.HornetQSession.createConsumer(HornetQSession.java:345)
      
      14:40:03,390 ERROR [STDERR]     at com.regiocom.bpo.randomservice.RandomJMSConsumer.<init>(RandomJMSConsumer.java:64)
      
      14:40:03,390 ERROR [STDERR]     at com.regiocom.bpo.randomservice.RandomServiceImpl.<clinit>(RandomServiceImpl.java:56)
      
      14:40:03,390 ERROR [STDERR]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      
      14:40:03,390 ERROR [STDERR]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      
      14:40:03,390 ERROR [STDERR]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      
      14:40:03,390 ERROR [STDERR]     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      
      14:40:03,390 ERROR [STDERR]     at java.lang.Class.newInstance0(Class.java:355)
      
      14:40:03,390 ERROR [STDERR]     at java.lang.Class.newInstance(Class.java:308)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.newInstance(NonSpringBusHolder.java:164)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:98)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:110)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.webservices.integration.deployers.WSDeploymentAspectDeployer.internalDeploy(WSDeploymentAspectDeployer.java:123)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827)
      
      14:40:03,390 ERROR [STDERR]     at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417)
      
      14:40:03,390 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:619)
      
      14:40:03,390 ERROR [STDERR] Caused by: HornetQException[errorCode=105 message=Unable to validate user: queueUser for check type CONSUME for address jms.queue.RandomQueue]
      
      14:40:03,390 ERROR [STDERR]     ... 65 more
      

       

       

      After reading some discussions on the net/here i think this is a hornetq bug.

      Are there any workaround for this?

       

       

      thank you

       

      Florian