1 Reply Latest reply on Oct 10, 2006 4:58 PM by Gavin King

    Could not register Synchronization

    Samuel Mendenhall Apprentice

      I have the java.lang.RuntimeException: org.hibernate.TransactionException: Could not register synchronization from time to time and I've fixed it by redeploying the app, but I am tired of doing that and I want to find a real solution.

      It is happening currently when I click view jobs to list out my jobs, then I wait a whlie, 15 minutes? and I click the delete button to delete a job and I get the exception:

      16:36:39,031 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.FacesException: Error calling action method of component with id _id14:_id16:0:_id68
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIData.broadcast(UIData.java:513)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.faces.el.EvaluationException: /viewJobs.xhtml @130,45 action="#{viewJobs.delete}": java.lang.RuntimeException: org.hibernate.TransactionException: Could not register synchronization
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       ... 28 more
      Caused by: java.lang.RuntimeException: org.hibernate.TransactionException: Could not register synchronization
       at org.jboss.ejb3.stateful.StatefulBeanContext.remove(StatefulBeanContext.java:273)
       at org.jboss.ejb3.AbstractPool.remove(AbstractPool.java:171)
       at org.jboss.ejb3.cache.simple.SimpleStatefulCache.remove(SimpleStatefulCache.java:299)
       at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:89)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:188)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       at $Proxy141.delete(Unknown Source)
       at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       at org.jboss.seam.interceptors.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:73)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
       at org.jboss.seam.ejb.SeamInterceptor.invokeInContexts(SeamInterceptor.java:196)
       at org.jboss.seam.ejb.SeamInterceptor.invoke(SeamInterceptor.java:169)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:156)
       at org.jboss.seam.interceptors.ClientSideInterceptor.interceptInvocation(ClientSideInterceptor.java:44)
       at org.jboss.seam.interceptors.ClientSideInterceptor.intercept(ClientSideInterceptor.java:38)\
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:589)
       at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
       at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
       ... 29 more
      Caused by: org.hibernate.TransactionException: Could not register synchronization
       at org.hibernate.transaction.CMTTransaction.registerSynchronization(CMTTransaction.java:159)
       at org.hibernate.ejb.EntityManagerImpl.close(EntityManagerImpl.java:59)
       at org.jboss.ejb3.stateful.StatefulBeanContext.closeExtendedPCs(StatefulBeanContext.java:284)
       at org.jboss.ejb3.stateful.StatefulBeanContext.remove(StatefulBeanContext.java:268)
       ... 60 more
      Caused by: javax.transaction.RollbackException: Already marked for rollback TransactionImpl:XidImpl[FormatId=257, GlobalId=localhost/126, BranchQual=, localId=126]
       at org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:635)
       at org.hibernate.transaction.CMTTransaction.registerSynchronization(CMTTransaction.java:156)
       ... 63 more
      
      


      viewJobs.xhtml
      ...
      <!-- Delete Job -->
      <h:column>
      <h:commandButton rendered="#{jobs.rowCount > 0}"
       type="submit"
       value="Delete"
       action="#{viewJobs.delete}" />
      </h:column>
      ...
      


      ViewJobsBean.java
      @Name("viewJobs")
      @Stateful
      @Scope(ScopeType.SESSION)
      public class ViewJobsBean implements ViewJobs {
      ....
      public String view() {
       Map parameters = new HashMap();
       StringBuffer queryString = new StringBuffer();
       queryString.append("from Job");
       Query query = em.createQuery(queryString.toString());
       jobs = (List<Job>) query.getResultList();
      
       //**********************************************************//
       // Refresh all of the jobs
       //**********************************************************//
       for(int x = 0; x < jobs.size(); x++){
       em.refresh(jobs.get(x));
       }
      
       return "viewJobs";
       }
      ....
      



      I did my google searching and didn't find really any definitive answers, so help would be greatly appreciated.


      persistence.xml:
      <persistence>
       <persistence-unit name="entityManager">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/jobsDatasource</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/jobsEntityManagerFactory"/>
       </properties>
       </persistence-unit>
      </persistence>
      


      components.xml
      <components>
      
       <component name="org.jboss.seam.core.init">
       <property name="myFacesLifecycleBug">@myFacesLifecycleBug@</property>
       <property name="jndiPattern">@jndiPattern@</property>
       </component>
      
       <!-- 120 second conversation timeout -->
       <component name="org.jboss.seam.core.manager">
       <property name="conversationTimeout">120000</property>
       </component>
      
       <component name="entityManager" class="org.jboss.seam.core.ManagedPersistenceContext">
       <property name="persistenceUnitJndiName">java:/jobsEntityManagerFactory</property>
       </component>
      
       <component class="org.jboss.seam.core.Ejb"
       installed="@embeddedEjb@"/>
      
      </components>
      


      jboss-beans.xml
      <?xml version="1.0" encoding="UTF-8"?>
      
      <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
       xmlns="urn:jboss:bean-deployer">
      
       <!-- nothing here -->
      
      </deployment>