|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Unable to register cleanup Synchronization with TransactionManagerI use bitronix 1.3 with a cluster of tomcat6 and hibernate.
When i deploy or redeploy a application, I get a hibernateexception "Unable to register cleanup Synchronization with TransactionManager". If restart tomcat cluster all work fine. |
|
|
Re: Unable to register cleanup Synchronization with TransactionManagerThat's a bit too vague to provide any help.
Could you please post the full stack trace and explain a bit how you actually configured BTM, how you deloyed it and how you're using it? |
|
|
Re: Unable to register cleanup Synchronization with TransactionManagerException Stacktrace
org.hibernate.HibernateException: Unable to register cleanup Synchronization with TransactionManager at it.cuneo.provincia.patterns.facade.SimpleHibernateFacade.readObject(SimpleHibernateFacade.java:118) at it.cuneo.provincia.jsf.AbstractJSFHandler.getObjectForModel(AbstractJSFHandler.java:278) at it.cuneo.provincia.jsf.AbstractJSFHandler.getObjectForModel(AbstractJSFHandler.java:309) at org.apache.jsp.sede_005fmodulo.view_005fdati_005ftecnici_005fsede_jsp._jspService(view_005fdati_005ftecnici_005fsede_jsp.java:127) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) ... (none references at bitronix packages) my facade it.cuneo.provincia.patterns.facade.SimpleHibernateFacade public Object readObject(Class classe, java.io.Serializable pk) throws HibernateException { if (pk == null) throw new HibernateException("Primary key not specified"); Session se = null; Object obj = null; try { this.openTransaction(); se = getHibernateSessionFactory().getCurrentSession(); obj = se.get(classe, pk); commit(); } catch (Exception e) { e.printStackTrace(); rollback(); throw new HibernateException(e.getMessage()); } finally { if (se != null && se.isOpen()) se.clear(); } return obj; } public void openTransaction() throws FacadeException { try { if (getUserTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) { getUserTransaction().begin(); } } catch (NotSupportedException e) { throw new FacadeException(e.getMessage()); } catch (SystemException e) { throw new FacadeException(e.getMessage()); } } public UserTransaction getUserTransaction() throws FacadeException { try { return (javax.transaction.UserTransaction) loadJndiResource( new InitialContext(), "java:comp/env/UserTransaction"); } catch (NamingException e) { throw new FacadeException(e.getMessage()); } } public void commit() throws Exception { try { UserTransaction currentTransaction = getUserTransaction(); if (currentTransaction != null && currentTransaction.getStatus() == Status.STATUS_ACTIVE) currentTransaction.commit(); } catch (Exception e) { e.printStackTrace(); throw e; } } public void rollback() { try { UserTransaction currentTransaction = getUserTransaction(); if (currentTransaction != null && currentTransaction.getStatus() == Status.STATUS_ACTIVE) currentTransaction.rollback(); } catch (Exception e) { System.out.println("Impossibile eseguire il rollback " + e.getMessage()); } }
|
|
|
Re: Unable to register cleanup Synchronization with TransactionManagerException Stacktrace org.hibernate.HibernateException: Unable to register cleanup Synchronization with TransactionManager at it.cuneo.provincia.patterns.facade.SimpleHibernateFacade.readObject(SimpleHibernateFacade.java:118) at it.cuneo.provincia.jsf.AbstractJSFHandler.getObjectForModel(AbstractJSFHandler.java:278) at it.cuneo.provincia.jsf.AbstractJSFHandler.getObjectForModel(AbstractJSFHandler.java:309) at org.apache.jsp.sede_005fmodulo.view_005fdati_005ftecnici_005fsede_jsp._jspService(view_005fdati_005ftecnici_005fsede_jsp.java:127) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) ... (none references at bitronix packages) my facade it.cuneo.provincia.patterns.facade.SimpleHibernateFacade public Object readObject(Class classe, java.io.Serializable pk) throws HibernateException { if (pk == null) throw new HibernateException("Primary key not specified"); Session se = null; Object obj = null; try { this.openTransaction(); se = getHibernateSessionFactory().getCurrentSession(); obj = se.get(classe, pk); commit(); } catch (Exception e) { e.printStackTrace(); rollback(); throw new HibernateException(e.getMessage()); } finally { if (se != null && se.isOpen()) se.clear(); } return obj; } public void openTransaction() throws FacadeException { try { if (getUserTransaction().getStatus() == Status.STATUS_NO_TRANSACTION) { getUserTransaction().begin(); } } catch (NotSupportedException e) { throw new FacadeException(e.getMessage()); } catch (SystemException e) { throw new FacadeException(e.getMessage()); } } public UserTransaction getUserTransaction() throws FacadeException { try { return (javax.transaction.UserTransaction) loadJndiResource( new InitialContext(), "java:comp/env/UserTransaction"); } catch (NamingException e) { throw new FacadeException(e.getMessage()); } } public void commit() throws Exception { try { UserTransaction currentTransaction = getUserTransaction(); if (currentTransaction != null && currentTransaction.getStatus() == Status.STATUS_ACTIVE) currentTransaction.commit(); } catch (Exception e) { e.printStackTrace(); throw e; } } public void rollback() { try { UserTransaction currentTransaction = getUserTransaction(); if (currentTransaction != null && currentTransaction.getStatus() == Status.STATUS_ACTIVE) currentTransaction.rollback(); } catch (Exception e) { System.out.println("Impossibile eseguire il rollback " + e.getMessage()); } } Ludovic Orban wrote: > > That's a bit too vague to provide any help. > > Could you please post the full stack trace and explain a bit how you > actually configured BTM, how you deloyed it and how you're using it? > -- View this message in context: http://old.nabble.com/Unable-to-register-cleanup-Synchronization-with-TransactionManager-tp26156662p26160155.html Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Unable to register cleanup Synchronization with TransactionManagerI think taht my problem is localized in this code (but I don't know where)
HIbernate JTASessionContext public class JTASessionContext implements CurrentSessionContext { public Session currentSession() throws HibernateException { TransactionManager transactionManager = factory.getTransactionManager(); if ( transactionManager == null ) { throw new HibernateException( "No TransactionManagerLookup specified" ); } Transaction txn = null; try { txn = transactionManager.getTransaction(); if ( txn == null ) { throw new HibernateException( "Unable to locate current JTA transaction" ); } if ( !JTAHelper.isInProgress( txn.getStatus() ) ) { // We could register the session against the transaction even though it is // not started, but we'd have no guarentee of ever getting the map // entries cleaned up (aside from spawning threads). throw new HibernateException( "Current transaction is not in progress" ); } } catch ( HibernateException e ) { throw e; } catch ( Throwable t ) { throw new HibernateException( "Problem locating/validating JTA transaction", t ); } Session currentSession = ( Session ) currentSessionMap.get( txn ); if ( currentSession == null ) { currentSession = buildOrObtainSession(); try { txn.registerSynchronization( buildCleanupSynch( txn ) );//exception is here } catch ( Throwable t ) { //********** why there ins't a t.printStackTrace() , so I can know excpetion type try { currentSession.close(); } catch ( Throwable ignore ) { log.debug( "Unable to release generated current-session on failed synch registration", ignore ); } throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" ); //************** this is excpetion } currentSessionMap.put( txn, currentSession ); } return currentSession; } Bitronix Transaction code public class BitronixTransaction implements Transaction, BitronixTransactionMBean { ... public void registerSynchronization(Synchronization synchronization) throws RollbackException, IllegalStateException, SystemException { //************** may be I forget a commit o rollback e call o is ther a timeout on session or transaction ?? if(status == 6) throw new IllegalStateException("transaction hasn't started yet"); if(status == 1) throw new BitronixRollbackException("transaction has been marked as rollback only"); if(isDone()) throw new IllegalStateException("transaction is done, cannot register any more synchronization"); if(log.isDebugEnabled()) log.debug("registering synchronization " + synchronization); synchronizationScheduler.add(synchronization, 0); } |
|
|
Re: Unable to register cleanup Synchronization with TransactionManagerWhat version of Hibernate are you using?
|
|
|
Re: Unable to register cleanup Synchronization with TransactionManagerI found problem and solution.
Bitronix marks as readrollbackonly a transation after a time out. So when I call getcurrentsession from Hibernate, hibernate tries to syncronize transaction and session and it calls the registerSynchronization bitronix's method, but this method lanch a exception as code below if(status == 1) throw new BitronixRollbackException("transaction has been marked as rollback only"); In my facade I add a little code like this: if (getUserTransaction().getStatus() == Status.STATUS_MARKED_ROLLBACK) { getUserTransaction().rollback(); getUserTransaction().begin(); } and now all works fine. I had difficult to find the solution becouse hibernate does't thow the bitronix exception but a own exception like throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" ); instead Thown t //where t is the Throwable hibernate exception p.s. I use hibernate 3.3
|
| Free embeddable forum powered by Nabble | Forum Help |