Error In Allocating A Connection. Cause Javax.transaction.rollbackexception
XA transactionsAgile Board ExportXMLWordPrintable Details Type: Bug Status: Open Priority: Major Resolution: Unresolved Affects Version/s: 4.0 Fix Version/s: None Component/s: jts Labels: None Environment: Reproducible on both Mac Mavericks and CentOS6 Description I'm currently using Glassfish 4.0 with Spring 3.1, ActiveMQ 5.8, and Postgres 9.2. I'm using XA Transactions for my JMS and JDBC resources. I have set a transaction timeout of 60 seconds and an xa-transaction-timeout of 120 seconds. I have also enabled leak detection at 10 seconds but have not enabled leak reclaim. There is a scenario where I have a message listener (using springs DefaultMessageListenerContainer) which takes a message off my JMS queue, performs some processing, and commits the results to my database. If the JMS processing takes longer than my transaction timeout, a javax.transaction.RollbackException is thrown which results in a leaked JDBC connection. I've narrowed the problem to what appears to be a bug in com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(ResourceSpec spec, ResourceAllocator alloc, ClientSecurityInfo info). What happens is this... 1) The message listener starts an XA transaction and enlists a JMS connection. 2) My application code performs some processing and attempts to persist the results after about 60 seconds. 3) Glassfish prepares a JDBC connection by marking it as busy (i.e. com.sun.enterprise.resource.pool.ConnectionPool.setResourceStateToBusy(ConnectionPool.java:324)). 4) Glassfish then attempts to hand the connection off to the transaction manager (i.e. com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(ResourceSpec spec, ResourceAllocator alloc, ClientSecurityInfo info) -> getResourceManager(spec).enlistResource(handle). 5) Before Glassfish is able to hand the connection off to the transaction manager (i.e. getResourceManager(spec).enlistResource(handle)), the PoolManagerImpl.getResource method tries to get the transaction (i.e. tran = getResourceManager(spec).getTransaction(). Since the timeout has occurred, this throws a PoolingException. Since the handoff to the transaction manager hasn't yet happened, the transaction manager can't/doesn't release the JDBC connection. After that, it appears that nobody ever calls ConnectionPool.setResourceStateToFree, so the connection is "leaked". It seems that the glassfish developers kind of knew this was a problem and handled it further down in PoolManagerImpl.getResource when actually enlisting the resource, bu
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x https://java.net/jira/browse/GLASSFISH-21221 Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why do I need to flush the connection pool each time I redeploy? up vote 15 down vote http://stackoverflow.com/questions/7810708/why-do-i-need-to-flush-the-connection-pool-each-time-i-redeploy favorite 4 I have successfully made a connection to a remote MySQL server through Glassfish, however each time I make a change to the code or XHTML files, I need to open the administrator panel of Glassfish and flush the connection pool, otherwise I get the following error when I just refresh the page. Has anybody experienced this? I can post code or other information if it is needed. HTTP Status 500 - type Exception report message descriptionThe server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: WELD-000049 Unable to invoke [method] @PostConstruct public com.myapp.QuestionController.initialize() on com.myapp.QuestionController@4635bd2a root cause org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke [method] @PostConstruct public com.myapp.interfaces.QuestionController.initialize() on com.myapp.interfaces.QuestionController@4635bd2a root cause java.lang.reflect.InvocationTargetException root cause javax.ejb.EJBException root cause javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: ja
here for a quick overview of the site Help Center Detailed answers to http://stackoverflow.com/questions/24135301/problems-with-routing-message-to-separate-errorqueue any questions you might have Meta Discuss the workings and https://samebug.io/exceptions/181877/java.sql.SQLException/error-in-allocating-a-connection-cause-connection?soft=false policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community error in Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Problems with routing message to separate errorQueue up vote 0 down vote favorite I have a MessageBean which reads from a Queue we'll name MainQ. If the execution error in allocating of the onMessage code throws a user-based Exception with a type we'll name UserException I want to catch this and put this message on a separate Queue named UserErrorQ. If the exception is not of this type, the Exception is thrown on to be handled by the DMQ. Here is my issue: in my catch block I attempt, through a ErrorQueueHandler, to put this new message on the UserErrorQ. This results in an error when I attempt to connect to the connectionFactory to send the message to the UserErrorQ. Apparently creating a new connection to a QueueConnectionFactory(javax.jms.ConnectionFactory) is causing problems Error: com.sun.messaging.jms.JMSException: MQRA:DCF:allocation failure:createConnection:Error in allocating a connection. Cause: javax.transaction.RollbackException at com.sun.messaging.jms.ra.DirectConnectionFactory._allocateConnection(DirectConnectionFactory.java:548) at com.sun.messaging.jms.ra.DirectConnectionFactory.createConnection(DirectConnectionFactory.java:265) at com.sun.messaging.jms.ra.DirectConnectionFactory.createConnection(DirectConnectionFactory.java:244)` MessageBean: @TransactionAttribute(TransactionAttributeType.REQUIRED) public void onMessage(Message message) { try{ . . }catch(Exception e){ if(isUserExceptionWrappedInException(e){ errorQueueHandler.sendToErrorQueue(message); } } } private boolean isUserExceptionWrappedInException(Throwable t) { if (t == null) return false; else if (t instanceof UserException) return true; else
help others java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Connection refused: connect. Error Code: 0 Stack Overflow | Artem Moskalev | 4 years ago 0 mark Glassfish @PersistenceContext Stack Overflow | 4 years ago | Artem Moskalev java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Connection refused: connect. Error Code: 0 find similars Connectors Runtime Embedded GlassFish Web EclipseLink (non-OSGi) Container Common org.englishonline.backing 0 0 mark Teste Automatizado: Codificação do UserTest - Curso JEE e JSE Loja Virtual Completa Parte 17 com.br | 11 months ago java.sql.SQLException: Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource Error Code: 0 find similars Connectors Runtime Embedded GlassFish Web EclipseLink (non-OSGi) Embedded GlassFish Web Kernel Classes 0 0 mark [1.2.4] Glassfish, Play, Connections problem Google Groups | 5 years ago | Илья Скорик org.hibernate.exception.GenericJDBCException: Cannot open connection find similars Connectors Runtime Embedded GlassFish Web Hibernate EJB Hibernate Hibernate 0 Speed up your debug routine! Automated exception search integrated into your IDE Test Samebug Integration for IntelliJ IDEA 0 mark JDBC Pool unavailable induce failed deployment Oracle Community | 4 years ago | Olivier Chorier Guest javax.resource.spi.ResourceAllocationException: Erreur lors de l'allocation d'une connexion. Cause : Connection could not be allocated because: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. find similars Connectors Runtime Embedded GlassFish Web 0 0 mark [GLASSFISH-21221] Transaction timeout can cause leaked resource connections for XA transactions - Java.net JIRA java.net | 9 months ago org.springframework.jdbc.Cann