3 Replies Latest reply on Sep 16, 2003 8:57 AM by Daniel Murygin

    CMT, my rollback doesn't seem to be working

    Alen Ribic Newbie

      I was hopping someone could maybe help me solve a problem with regards to JBoss
      application server.
      Here it goes...

      I'm using JBoss 3.2.1 at this stage and am trying to make use of the JBossTX
      for handling managed transactions.


      I have deployed a Stateless Session Bean (using CMT with */Required) that
      has a method named createPerson(...).
      This method manipulates a DTO and passes it on to my underlying persistence
      manager that stores the person's info into the underlying datastore. My
      datastore is a MySQL 3.x DB and I'm using a MySQL Connector/J 3.0.7 Stable

      Session bean code snippet

      public void createPerson(Person p) {
      Session s = null;
      try {
      Context ctx = new InitialContext();
      SessionFactory factory =
      (SessionFactory) ctx.lookup("java:/hibernate/HibernateFactory");

      s = factory.openSession();


      if (1==1) {
      throw new Exception("JTS test...");
      } catch(Exception e) {
      // this throw should automatically perform a rollback
      throw new EJBException(
      "Transaction failed: " + e.getMessage());
      } finally {
      if(s!=null) try { s.close(); } catch(Exception e) {}

      Now as you can see above, I throw an Exception that rethrows a system-level
      exception named EJBException.
      In this case, Container should automatically rollback the running
      However my database shows that INSERT statement has been committed as it
      reflects the inserted change.

      Alternatively, I have tried to set the ROLLBACK-ONLY using the session
      setRollbackOnly method and then throw an application-level exception.
      Unfortunately this didn't work either.

      My transaction-service.xml is running with default settings.
      And I'm running a service for MySQL datasource using the




      Do I perhaps require to use the XA protocol for some reason?

      Any suggestions or ideas that I can try to help me find the solution to my
      problem, much appreciated.
      Maybe a way in which I can monitor the JBossTX invoking the begins, commits
      and rollbacks on my methods?