6 Replies Latest reply on Apr 3, 2017 7:23 AM by Bernard H

    Unable to get managed connection for java:/JmsXA

    Alisson Vieira Newbie

      I've got this error always production environment but I don't know why it's happening. This error happens when the user log out and login again, in my method of login I send a message for JMS .I'm using JMS 2 with Wildfly 8.1

      thanks!

       

      @MessageDriven(name = "LogSistemaQueue", activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/LogSistemaAsynchronous"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
      public class LogSistemaAsynchronous implements MessageListener {...}

      public class LogSistemaUtil {
      @Inject
      @SuppressWarnings("cdi-ambiguous-dependency")
      private JMSContext context;

      @Resource(lookup = "java:/queue/LogSistemaAsynchronous")
      private Queue queue;

      public void adicionarLog(Usuario usuario, TipoLogEnum tipo, String acao) throws Exception {
        Map<String, Object> parametros = new HashMap<String, Object>();

        parametros.put("usuario", usuario.getCodigo());
        parametros.put("tipo", tipo.name());
        parametros.put("acao", acao);

        context.createProducer().send(queue, parametros);
      }

      public void adicionarLog(Atendimento atendimento, Usuario usuario, TipoLogEnum tipo, String acao) throws Exception {
        Map<String, Object> parametros = new HashMap<String, Object>();

        parametros.put("atendimento", atendimento.getCodigo());
        parametros.put("usuario", usuario.getCodigo());
        parametros.put("tipo", tipo.name());
        parametros.put("acao", acao);

        context.createProducer().send(queue, parametros);
      }
      }

        • 2. Re: Unable to get managed connection for java:/JmsXA
          Alisson Vieira Newbie

          2014-07-30 08:29:31,299 ERROR [stderr] (default task-37) java.lang.RuntimeException: javax.jms.JMSRuntimeException: Could not create a session: IJ000453: Unable to get managed connection for java:/JmsXA

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at org.jboss.as.messaging.deployment.JMSContextProducer$JMSContextWrapper.getDelegate(JMSContextProducer.java:217)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at org.jboss.as.messaging.deployment.JMSContextProducer$JMSContextWrapper.createProducer(JMSContextProducer.java:239)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at br.com.virtualsistemas.correspondente.util.LogSistemaUtil.adicionarLog(LogSistemaUtil.java:30)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at br.com.virtualsistemas.correspondente.controller.LoginController.logar(LoginController.java:60)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at java.lang.reflect.Method.invoke(Method.java:606)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at com.sun.el.parser.AstValue.invoke(AstValue.java:275)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)

          2014-07-30 08:29:31,300 ERROR [stderr] (default task-37) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at javax.faces.component.UICommand.broadcast(UICommand.java:315)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)

          2014-07-30 08:29:31,301 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)

          2014-07-30 08:29:31,302 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at java.lang.Thread.run(Thread.java:724)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) Caused by: javax.jms.JMSRuntimeException: Could not create a session: IJ000453: Unable to get managed connection for java:/JmsXA

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRAConnectionFactoryImpl.createContext(HornetQRAConnectionFactoryImpl.java:509)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at org.jboss.as.messaging.deployment.JMSContextProducer$JMSContextWrapper.create(JMSContextProducer.java:180)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at org.jboss.as.messaging.deployment.JMSContextProducer$JMSContextWrapper.getDelegate(JMSContextProducer.java:201)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) ... 56 more

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) Caused by: javax.jms.JMSException: Could not create a session: IJ000453: Unable to get managed connection for java:/JmsXA

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRASessionFactoryImpl.allocateConnection(HornetQRASessionFactoryImpl.java:1002)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRASessionFactoryImpl.createSession(HornetQRASessionFactoryImpl.java:566)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRASessionFactoryImpl.createSession(HornetQRASessionFactoryImpl.java:822)

          2014-07-30 08:29:31,303 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRASessionFactoryImpl.createSession(HornetQRASessionFactoryImpl.java:828)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRAConnectionFactoryImpl.validateUser(HornetQRAConnectionFactoryImpl.java:555)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRAConnectionFactoryImpl.createContext(HornetQRAConnectionFactoryImpl.java:499)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) ... 58 more

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/JmsXA

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:440)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:422)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:513)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.hornetq.ra.HornetQRASessionFactoryImpl.allocateConnection(HornetQRASessionFactoryImpl.java:948)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) ... 63 more

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:512)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:454)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:426)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:379)

          2014-07-30 08:29:31,304 ERROR [stderr] (default task-37) ... 66 more

          • 3. Re: Unable to get managed connection for java:/JmsXA
            Justin Bertram Master

            Here's the culprit:

             

            Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])

             

            This means the connection pool is exhausted. 

             

            Also, based on the stack-trace I'd say this doesn't have anything to do with your MDB.

            • 4. Re: Unable to get managed connection for java:/JmsXA
              Alisson Vieira Newbie

              what can I do to solve this problem?

              this problem happens when I try to login in my system. How you can see in the log, it happens in this line context.createProducer().send(queue, parametros);

               

               

              public void adicionarLog(Usuario usuario, TipoLogEnum tipo, String acao) throws Exception {

                Map<String, Object> parametros = new HashMap<String, Object>();

               

               

                parametros.put("usuario", usuario.getCodigo());

                parametros.put("tipo", tipo.name());

                parametros.put("acao", acao);

               

               

                context.createProducer().send(queue, parametros);

              }

              • 5. Re: Unable to get managed connection for java:/JmsXA
                Jesper Pedersen Master

                There is likely a leak if your pool is configured correctly. You can use the IronJacamar leak detector to find it, http://www.ironjacamar.org/doc/userguide/1.1/en-US/html/ch04.html#configuration_ironjacamar_leakpool

                • 6. Re: Unable to get managed connection for java:/JmsXA
                  Bernard H Newbie

                  I got this error on several occasions. Clearly, you do exhaust the connections on the JmsXA pool and this not only affects the one MDB that does not release resources, but can affect any other MDB in the same EE container! In other words, you can break your whole system by deploying a single MDB in a separate JAR WAR or EAR that leaks resources.

                   

                  The culprit is usually a missing jmsContext.close().

                   

                  Here is a template for a well-conditioned MDB, a simple queue-to-queue bridge with comments explaining the issues:

                   

                  package biz.artofe.mailout;

                   

                  import javax.annotation.PreDestroy;

                  import javax.annotation.Resource;

                  import javax.ejb.ActivationConfigProperty;

                  import javax.ejb.EJBException;

                  import javax.ejb.MessageDriven;

                  import javax.jms.ConnectionFactory;

                  import javax.jms.DeliveryMode;

                  import javax.jms.JMSContext;

                  import javax.jms.JMSException;

                  import javax.jms.JMSProducer;

                  import javax.jms.Message;

                  import javax.jms.MessageListener;

                  import javax.jms.Queue;

                  import org.slf4j.Logger;

                  import org.slf4j.LoggerFactory;

                  /**

                  * Template Message-Driven Bean in JBoss EAP7 context with embedded ActiveMQ/Artemis

                  * @author bernardH

                  */

                  @MessageDriven( name="MailRelay",

                    activationConfig = {

                       @ActivationConfigProperty(propertyName= "destinationLookup",propertyValue="java:/jms/queue/MyInputQueue"),

                       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")

                    })

                  @org.jboss.ejb3.annotation.Pool("mdb-broker-10") /* You will be well inspired to use bean pool defs in EAP7 to manage concurrent listeners */

                  public class MailRelay implements MessageListener {

                   

                    final Logger logger = LoggerFactory.getLogger(MailRelay.class);

                   

                    // inject queue connection factory of the inner JMS provider

                    @Resource(name = "JmsXA")

                    private ConnectionFactory jmsConnectionFactory;

                     

                    @Resource(name = "java:/jms/queue/MyOutputQueue")

                    private Queue outQueue;

                    private JMSContext jmsContext;

                    private JMSProducer jmsProducer;

                   

                  public void onMessage(Message message) {

                     try {

                            logger.debug( "onMessage() handles one message ... "));

                            // YES of course you immediately think about initializing the jmsProducer and/or at least the jmsContext in a @PostConstruct method

                             // and re-use it ... so please try, and see all errors / instabilities you get; please do make soak tests with high volumes, and you'll see...

                             // In the end, the only way to get the reliability we need is with on-the-fly initialization, and hopefully: performance impact is minimal

                            jmsContext = jmsConnectionFactory.createContext(JMSContext.SESSION_TRANSACTED);

                            jmsProducer = jmsContext.createProducer().setDeliveryMode(DeliveryMode.PERSISTENT);

                            jmsProducer.send( outQueue, message);

                          

                     } catch (JMSException e) {

                            logger.error("FAILED JMS relaying, {}:{}",e.getClass().getName(), e.getMessage() ); // you may prefer a string'ified version of the stack trace here

                            throw new EJBException(e);

                     } finally {

                            // THIS IS CRITICAL: ... we were forced to create the jmsContext on-the-fly, henceforth:

                            // if we forget to close the jmsContext, we will hold connections in the pool and then DO prevent other MDB's to work!!!!

                            // you'll get: ERROR [org.jboss.as.ejb3.invocation] ... Could not create a session: IJ000453: Unable to get managed connection for java:/JmsXA

                            if (jmsContext!=null) jmsContext.close();

                     }

                    }

                  }