0 Replies Latest reply on May 23, 2008 4:21 PM by Sergey Zhigunov

    JMS authentication problem

    Sergey Zhigunov Newbie

      Hi,

      This is the problem: when I try to receive from the remote queue the first time and my principal
      is not in the authentication cache of the remote server, I get JMSSecurityException.
      At the same time authentication does happen. The principal shows up in the authentication cache
      and next time receive works.

      Here are some details.

      Remote server:
      JBoss 4.2.2 + JBM 1.4.0.SP3; has a queue deployed on it; the messaging service is protected
      by custom security module which authenticates against the application database.

      Local server:
      JBoss 4.2.2 + JBM 1.4.0.SP3; has JMS JCA adopter configured. Receiver is an MBean.
      The code is essentially the following:

      // Get factory from local <tx-connection-factory> via JNDI
      Connection c = factory.createConnection(user, pass);
      Session session = conn.createSession(true, 0);
      MessageConsumer consumer = session.createConsumer(queue, jmsCtx.getSelector());

      CreateSession call throws the exception in the situation described above. Interesting detail is that if I put a break point
      and wait for a few seconds before executing createSession: it works. It feels like a race condition:
      createConnection triggers authentication but does not block.

      Custom JAAS login module mentioned above pretty simple and successfully used for web apps and EJB security.

      Any help / thoughts will be appreciated.

      org.jboss.resource.JBossResourceException: Unable to setup connection; - nested throwable: (javax.jms.JMSSecurityException: User bus-sys-user is NOT authenticated)
      at org.jboss.resource.adapter.jms.JmsManagedConnection.setup(JmsManagedConnection.java:778)
      at org.jboss.resource.adapter.jms.JmsManagedConnection.(JmsManagedConnection.java:184)
      at org.jboss.resource.adapter.jms.JmsManagedConnectionFactory.createManagedConnection(JmsManagedConnectionFactory.java:106)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:577)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:262)
      at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:500)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:341)
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:315)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:396)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
      at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.allocateConnection(JmsSessionFactoryImpl.java:389)
      at org.jboss.resource.adapter.jms.JmsSessionFactoryImpl.createSession(JmsSessionFactoryImpl.java:369)
      at com.teoco.common.bus.impl.jms.JmsListener.receive(JmsListener.java:123)
      at com.teoco.common.bus.impl.jms.JmsListener.receiveInTransaction(JmsListener.java:97)
      at com.teoco.common.bus.impl.jms.JmsListener.run(JmsListener.java:74)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.jms.JMSSecurityException: User bus-sys-user is NOT authenticated
      at org.jboss.jms.server.security.SecurityMetadataStore.authenticate(SecurityMetadataStore.java:202)
      at org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint.createConnectionDelegateInternal(ServerConnectionFactoryEndpoint.java:222)
      at org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint.createConnectionDelegate(ServerConnectionFactoryEndpoint.java:162)
      at org.jboss.jms.server.endpoint.advised.ConnectionFactoryAdvised.org$jboss$jms$server$endpoint$advised$ConnectionFactoryAdvised$createConnectionDelegate$aop(ConnectionFactoryAdvised.java:108)
      at org.jboss.jms.server.endpoint.advised.ConnectionFactoryAdvised.createConnectionDelegate(ConnectionFactoryAdvised.java)
      at org.jboss.jms.wireformat.ConnectionFactoryCreateConnectionDelegateRequest.serverInvoke(ConnectionFactoryCreateConnectionDelegateRequest.java:91)
      at org.jboss.jms.server.remoting.JMSServerInvocationHandler.invoke(JMSServerInvocationHandler.java:143)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:795)
      at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
      at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:387)
      at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
      at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
      at org.jboss.remoting.Client.invoke(Client.java:1634)
      at org.jboss.remoting.Client.invoke(Client.java:548)
      at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.org$jboss$jms$client$delegate$ClientConnectionFactoryDelegate$createConnectionDelegate$aop(ClientConnectionFactoryDelegate.java:167)
      at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.invokeNext(ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.java)
      at org.jboss.jms.client.container.StateCreationAspect.handleCreateConnectionDelegate(StateCreationAspect.java:83)
      at org.jboss.aop.advice.org.jboss.jms.client.container.StateCreationAspect0.invoke(StateCreationAspect0.java)
      at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.invokeNext(ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.java)
      at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.createConnectionDelegate(ClientConnectionFactoryDelegate.java)
      at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:205)
      at org.jboss.jms.client.JBossConnectionFactory.createXAConnection(JBossConnectionFactory.java:128)
      at org.jboss.jms.ConnectionFactoryHelper.createConnection(ConnectionFactoryHelper.java:78)
      at org.jboss.resource.adapter.jms.JmsManagedConnection.setup(JmsManagedConnection.java:743)
      ... 15 more

      If the connection is already in the pool, and I flush authentication cache - it behaves similar but breaks on creatConsumer()