[jboss-user] [JBoss Seam] - Re: How can I create seam context etc in httpservlet

umarzubair do-not-reply at jboss.com
Sun Oct 15 06:23:19 EDT 2006


Now insert/updates are working.
I have done two changes.
1. At start of httpservlet, I have written lines of code
        // to start transaction, it is required for any update, insert
        try {
            if (!Transactions.isTransactionActiveOrMarkedRollback()) {
                //log.debug("beginning transaction prior to phase: " + phaseId);
                Transactions.getUserTransaction().begin();
            }
        }
        catch (Exception e) {
            throw new IllegalStateException("Could not start transaction", e);
        }

2. At end of servlet, I have used following line of code
        // it is required to commit or rollback transaction

        try {
            if (Transactions.isTransactionActive()) {
                Transactions.getUserTransaction().commit();
            }
            else if (Transactions.isTransactionMarkedRollback()) {
                //                log.debug("rolling back transaction after phase: " + phaseId);
                Transactions.getUserTransaction().rollback();
            }
        }
        catch (Exception e) {
            throw new IllegalStateException("Could not commit transaction", e);
        }


Umar

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978376#3978376

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978376



More information about the jboss-user mailing list