javax.transaction.RollbackException: Transaction marked for rollback. No useful information, no reason WHY it's marked for rollback. An alternative way to achieve that useless error message would be: tx.begin(); Thing t = em.find(Thing.class,thingId); t.changeField("new value"); em.persist(new SubThing(t); tx.commit(); What I gather is that for some reason it doesn't like it when the following conditions happen to Entity e within a transaction: 1) e has a field which is modified 2) e has a collection of other entities which gains a new entity (perhaps when one is modified too?) 3) the entity of which there is a collection within e has a reference to e It's totally fine if you only change the field, or only add the entity to the collection. Another question, are there known differences when using JPA with hibernate as the provider within Glassfish? All the tutorials I've read, and the Manning Java Persistence with Hibernate book use the following to get a reference to an EntityManager: EntityManagerFactory emf = Persistence.createEntityManagerFactory("nameOfPersistenceUnit"); EntityManager em = emf.createEntityManager(); But from the very beginning of my new project (using Hibernate as a JPA provider in Glassfish) that threw an exception every time I tried it. They also all get a hold of a transaction with: EntityTransaction tx = em.getTransaction(); tx.begin(); But every time I've tried that, I get an exception saying: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

Oracle Community | rwillie6 | 9 years ago
  1. 0

    Cannot modify entity and collection within entity in same transaction

    Oracle Community | 9 years ago | rwillie6
    javax.transaction.RollbackException: Transaction marked for rollback. No useful information, no reason WHY it's marked for rollback. An alternative way to achieve that useless error message would be: tx.begin(); Thing t = em.find(Thing.class,thingId); t.changeField("new value"); em.persist(new SubThing(t); tx.commit(); What I gather is that for some reason it doesn't like it when the following conditions happen to Entity e within a transaction: 1) e has a field which is modified 2) e has a collection of other entities which gains a new entity (perhaps when one is modified too?) 3) the entity of which there is a collection within e has a reference to e It's totally fine if you only change the field, or only add the entity to the collection. Another question, are there known differences when using JPA with hibernate as the provider within Glassfish? All the tutorials I've read, and the Manning Java Persistence with Hibernate book use the following to get a reference to an EntityManager: EntityManagerFactory emf = Persistence.createEntityManagerFactory("nameOfPersistenceUnit"); EntityManager em = emf.createEntityManager(); But from the very beginning of my new project (using Hibernate as a JPA provider in Glassfish) that threw an exception every time I tried it. They also all get a hold of a transaction with: EntityTransaction tx = em.getTransaction(); tx.begin(); But every time I've tried that, I get an exception saying: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
  2. 0

    <DispatchHelper::handleMessage> failed to handle message

    Oracle Community | 9 years ago | Bogumil Laska
    javax.transaction.RollbackException: returning error in transaction: Exception [TOPLINK-6004] (Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)): oracle.toplink.exceptions.QueryException Exception Description: The object [com.collaxa.cube.engine.sensor.sa.publisher.toplink.model.ActivitySensorValue@10e4689], of class [class com.collaxa.cube.engine.sensor.sa.publisher.toplink.model.ActivitySensorValue], with identity hashcode (System.identityHashCode()) [17,712,777], is not from this UnitOfWork object space, but the parent session's. The object was never registered in this UnitOfWork, but read from the parent session and related to an object registered in the UnitOfWork. Ensure that you are correctly registering your objects. If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to help debug where the error occurred. For more information, see the manual or FAQ.
  3. 0

    <DispatchHelper::handleMessage> failed to handle message

    Oracle Community | 9 years ago | Bogumil Laska
    javax.transaction.RollbackException: returning error in transaction: Exception [TOPLINK-6004] (Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)): oracle.toplink.exceptions.QueryException Exception Description: The object [com.collaxa.cube.engine.sensor.sa.publisher.toplink.model.ActivitySensorValue@10e4689], of class [class com.collaxa.cube.engine.sensor.sa.publisher.toplink.model.ActivitySensorValue], with identity hashcode (System.identityHashCode()) [17,712,777], is not from this UnitOfWork object space, but the parent session's. The object was never registered in this UnitOfWork, but read from the parent session and related to an object registered in the UnitOfWork. Ensure that you are correctly registering your objects. If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to help debug where the error occurred. For more information, see the manual or FAQ.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Exception on commit

    Oracle Community | 1 decade ago | 219855
    javax.transaction.RollbackException: The transaction has been marked for rollback (javax.ejb.EJBException)
  6. 0

    <DispatchHelper::handleMessage> failed to handle message

    Oracle Community | 9 years ago | Bogumil Laska
    javax.ejb.EJBException: An exception occurred during transaction completion: ; nested exception is: javax.transaction.RollbackException: returning error in transaction: Exception [TOPLINK-6004] (Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)): oracle.toplink.exceptions.QueryException Exception Description: The object [com.collaxa.cube.engine.sensor.sa.publisher.toplink.model.ActivitySensorValue@10e4689], of class [class com.collaxa.cube.engine.sensor.sa.publisher.toplink.model.ActivitySensorValue], with identity hashcode (System.identityHashCode()) [17,712,777], is not from this UnitOfWork object space, but the parent session's. The object was never registered in this UnitOfWork, but read from the parent session and related to an object registered in the UnitOfWork. Ensure that you are correctly registering your objects. If you are still having problems, you can use the UnitOfWork.validateObjectSpace() method to help debug where the error occurred. For more information, see the manual or FAQ.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. javax.transaction.RollbackException

      Transaction marked for rollback. No useful information, no reason WHY it's marked for rollback. An alternative way to achieve that useless error message would be: tx.begin(); Thing t = em.find(Thing.class,thingId); t.changeField("new value"); em.persist(new SubThing(t); tx.commit(); What I gather is that for some reason it doesn't like it when the following conditions happen to Entity e within a transaction: 1) e has a field which is modified 2) e has a collection of other entities which gains a new entity (perhaps when one is modified too?) 3) the entity of which there is a collection within e has a reference to e It's totally fine if you only change the field, or only add the entity to the collection. Another question, are there known differences when using JPA with hibernate as the provider within Glassfish? All the tutorials I've read, and the Manning Java Persistence with Hibernate book use the following to get a reference to an EntityManager: EntityManagerFactory emf = Persistence.createEntityManagerFactory("nameOfPersistenceUnit"); EntityManager em = emf.createEntityManager(); But from the very beginning of my new project (using Hibernate as a JPA provider in Glassfish) that threw an exception every time I tried it. They also all get a hold of a transaction with: EntityTransaction tx = em.getTransaction(); tx.begin(); But every time I've tried that, I get an exception saying: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()

      at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction()
    2. Hibernate EJB
      AbstractEntityManagerImpl.getTransaction
      1. org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:317)
      1 frame
    3. Common Utilities
      EntityManagerWrapper.getTransaction
      1. com.sun.enterprise.util.EntityManagerWrapper.getTransaction(EntityManagerWrapper.java:565)
      1 frame
    4. com.stag.servlet
      AdminServlet.doPost
      1. com.stag.servlet.AdminServlet.doPost(AdminServlet.java:156)
      1 frame
    5. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      2 frames
    6. Glassfish Core
      StandardPipeline.doInvoke
      1. org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
      2. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
      3. org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
      4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
      5. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
      6. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
      6 frames
    7. Glassfish
      WebPipeline.invoke
      1. com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
      1 frame
    8. Glassfish Core
      ContainerBase.invoke
      1. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
      2. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
      3. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
      4. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
      5. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
      6. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
      7. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
      8. org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
      9. org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
      10. org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
      10 frames
    9. org.apache.coyote
      CoyoteAdapter.service
      1. org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
      1 frame
    10. Glassfish Core
      TaskBase.run
      1. com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
      2. com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
      3. com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
      4. com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
      5. com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
      6. com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
      7. com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
      7 frames
    11. Grizzly HTTP
      SSLWorkerThread.run
      1. com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
      1 frame