8 Replies Latest reply: Apr 18, 2012 10:30 AM by varsha g RSS

    Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA

    varsha g Newbie

      When I'm trying to add to the message sending queue, The messages are successfully added to the queue, but the MDB is not working properly OR the messages are not fetched. It throws the following error :

       

      06:49:15,600 ERROR [org.hornetq.ra.HornetQRASessionFactoryImpl] (http--0.0.0.0-8080-61)c

          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:390)

          at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368)

          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:464)

          at org.hornetq.ra.HornetQRASessionFactoryImpl.allocateConnection(HornetQRASessionFactoryImpl.java:837)

          at org.hornetq.ra.HornetQRASessionFactoryImpl.createSession(HornetQRASessionFactoryImpl.java:470)

          at com.ecomm.ultimatesms.messaging.feedback.feedback.processRequest(feedback.java:110) [classes:]

          at com.ecomm.ultimatesms.messaging.feedback.feedback.doGet(feedback.java:37) [classes:]

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.14.Final.jar:]

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.14.Final.jar:]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.14.Final.jar:]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.14.Final.jar:]

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.14.Final.jar:]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.14.Final.jar:]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.14.Final.jar:]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.14.Final.jar:]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.14.Final.jar:]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.14.Final.jar:]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.14.Final.jar:]

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]

      Caused by: javax.resource.ResourceException: IJ000658: Unexpected throwable while trying to create a connection: null

          at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:371)

          at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:397)

          at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:365)

          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:329)

          ... 21 more

      Caused by: javax.resource.ResourceException: Error during setup

          at org.hornetq.ra.HornetQRAManagedConnection.<init>(HornetQRAManagedConnection.java:152)

          at org.hornetq.ra.HornetQRAManagedConnectionFactory.createManagedConnection(HornetQRAManagedConnectionFactory.java:180)

          at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761)

          at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:343)

          ... 24 more

      Caused by: javax.resource.ResourceException: Failed to create session factory

          at org.hornetq.ra.HornetQRAManagedConnection.setup(HornetQRAManagedConnection.java:821)

          at org.hornetq.ra.HornetQRAManagedConnection.<init>(HornetQRAManagedConnection.java:141)

          ... 27 more

      Caused by: javax.jms.JMSException: Failed to create session factory

          at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)

          at org.hornetq.jms.client.HornetQConnectionFactory.createXAConnection(HornetQConnectionFactory.java:155)

          at org.hornetq.jms.client.HornetQConnectionFactory.createXAConnection(HornetQConnectionFactory.java:150)

          at org.hornetq.ra.HornetQRAManagedConnection.setup(HornetQRAManagedConnection.java:810)

          ... 28 more

      Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]

          at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:769)

          at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)

          ... 31 more.

       

      Please can someone guide me how to resolve it. Thanks.

        • 2. Re: Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA
          varsha g Newbie

          These are the configurations of the standalone-full.xml file :

           

                 <pools>

                          <bean-instance-pools>

                              <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                              <strict-max-pool name="mdb-strict-max-pool" max-pool-size="1" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>

                          </bean-instance-pools>

                      </pools>

           

                      <address-settings>

                              <address-setting match="#">

                                  <dead-letter-address>jms.queue.DLQ</dead-letter-address>

                                  <expiry-address>jms.queue.ExpiryQueue</expiry-address>

                                  <redelivery-delay>0</redelivery-delay>

                                  <max-size-bytes>524288000</max-size-bytes>

                                  <page-size-bytes>52428800</page-size-bytes>

                                  <address-full-policy>PAGE</address-full-policy>

                                  <message-counter-history-day-limit>10</message-counter-history-day-limit>

                              </address-setting>

                        </address-settings>

           

                         <pooled-connection-factory name="hornetq-ra">

                                  <transaction mode="xa"/>

                                  <connectors>

                                      <connector-ref connector-name="in-vm"/>

                                  </connectors>

                                  <entries>

                                      <entry name="java:/JmsXA"/>

                                  </entries>

                              </pooled-connection-factory>

           

                               <jms-queue name="testQueue">

                                  <entry name="queue/test"/>

                                  <entry name="java:jboss/exported/jms/queue/test"/>

                              </jms-queue>

          • 3. Re: Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA
            Andy Taylor Master

            that all looks fine, could you provide some instructions on how to reproduce

            • 4. Re: Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA
              varsha g Newbie

              I was testing my server by adding 100 000 messages to queue. They all are added to the queue, but Its not getting listened by the MDB.

               

              After leaving the server idle for a while we get the  following error : Caused by: java.lang.IllegalStateException: Cannot create session factory, server locator is closed (maybe it has been garbage collected)

               

              After this when I'm trying to send the message to queue, the message will be added to the queue but  it does not get recieved from the queue.

               

              When I restart the server, I'm able to add and recive messages from the queue.

              • 5. Re: Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA
                Andy Taylor Master

                we really need something we can run, a test similar to what your code does

                • 6. Re: Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA
                  varsha g Newbie

                  The following is test code :

                   

                          String destinationName = "queue/test";

                   

                          Context ic = null;

                          QueueConnectionFactory cf = null;

                          Connection connection =  null;

                          MessageProducer publisher = null;

                          Session session = null;

                          try {       

                              Properties props = new Properties();

                              props.setProperty("java.naming.factory.initial", "org.jboss.as.naming.InitialContextFactory");

                              props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

                              props.setProperty("java.naming.provider.url", "localhost");

                              ic = new InitialContext(props);

                              cf = (QueueConnectionFactory)ic.lookup("java:/JmsXA");

                              Queue queue = (Queue)ic.lookup(destinationName);

                   

                              connection = cf.createConnection();

                              session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                              publisher = session.createProducer(queue);

                   

                              connection.start();

                   

                              FeedbackMessageBean mymesage=new FeedbackMessageBean();

                              mymesage.setStatus( "16");

                              mymesage.setDestination("27718681922");

                              mymesage.setTimeDate("2012-07-05+08:08:10");

                              mymesage.setSmsID("0a609648-ad1c-4bca-90c5-19ca8ce38bb0");

                              mymesage.setMessage("Test Message");

                   

                              ObjectMessage  msg = session.createObjectMessage(mymesage);

                   

                              publisher.send(msg);

                              System.out.println("Message sento to the JMS Provider");

                   

                          }

                          catch (Exception exc) {

                              exc.printStackTrace();

                          }

                          finally {   

                              if(ic != null){

                                  try {

                                      ic.close();

                                  } catch (NamingException e) {

                                      e.printStackTrace();

                                  }

                              }   

                              if(publisher != null){

                                  try {

                                      publisher.close();

                                  } catch (JMSException e) {

                                      e.printStackTrace();

                                  }

                              }

                              if(session != null){

                                  try {

                                      session.close();

                                  } catch (JMSException e) {

                                      e.printStackTrace();

                                  }

                              }   

                              if (connection != null)   {

                                  try {

                                      connection.close();

                                  } catch (JMSException e) {                  

                                      e.printStackTrace();

                                  }

                              }

                  • 7. Re: Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA
                    Andy Taylor Master

                    you need to give me something i can reproduce, i.e. all server configs, how you start the server and a test, not just some java code, i dont know where your code should live, is it a standalone client, mdb, session bean etc etc.

                    • 8. Re: Could not create session: javax.resource.ResourceException: Unable to get managed connection for java:/JmsXA
                      varsha g Newbie

                      I have a test servlet which sends messages to the JMS queue. And I have MDB which fetches the messages from teh queue.

                      I have attached my TestServlet and MDB code. I have also attached my standalone-full.xml.

                       

                      These are the HornetQ settings for the file standalone-full.xml:

                       

                          <subsystem xmlns="urn:jboss:domain:messaging:1.2">

                                 <hornetq-server>

                                     <persistence-enabled>true</persistence-enabled>

                                     <journal-type>ASYNCIO</journal-type>

                                     <journal-file-size>10485760</journal-file-size>

                                     <journal-min-files>2</journal-min-files>

                                 <journal-max-io>500</journal-max-io>

                       

                          </hornetq-server>

                          </subsystem>

                       

                           <address-settings>

                                         <address-setting match="#">

                       

                                             <dead-letter-address>jms.queue.DLQ</dead-letter-address>

                       

                                             <expiry-address>jms.queue.ExpiryQueue</expiry-address>

                       

                                             <redelivery-delay>0</redelivery-delay>

                       

                                             <max-size-bytes>104857600</max-size-bytes>

                       

                                             <page-size-bytes>10485760</page-size-bytes>

                       

                                             <address-full-policy>PAGE</address-full-policy>       <message-counter-history-day-limit>10</message-counter-history-day-limit>

                                         </address-setting>

                                 </address-settings>

                       

                       

                      When I test the JMS queue using JMeter by sending 100 000 messages to queue it throws the following exception on 2gb RAM :-

                       

                         ---    19:30:23,747 ERROR [org.apache.catalina.connector.CoyoteAdapter] An exception or error occurred in the container during the request processing: java.lang.RuntimeException: java.lang.IllegalStateException

                          at org.jboss.as.web.ThreadSetupBindingListener.unbind(ThreadSetupBindingListener.java:67) [jboss-as-web-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]

                       

                       

                         ---  19:30:23,430 ERROR [stderr] javax.jms.JMSException: Could not create a session: IJ000453: Unable to get managed connection for java:/JmsXA

                       

                       

                      But I tested the same on 4gb RAM. It works fine without any errors.

                       

                      As I'm writing the messages to the page, Why is there a RAM issue?

                       

                      Please let me know what can be the issue?

                       

                      Thanks.