EJB nested transaction handling.

My situation closely relates to the round-trip planning problem. I have a series of say 5 EJBs (session and entity both involved) doing a particular work. If an error occurs at the EJB 5 stage, I don't want to rollback the work done in EJB 1 and 2 but I want EJB 3 onwards to rollback. Is this kind of nested transaction model possible. Please note that I want to use container-managed-transactions. If not possible, please guide me how can I use bean-managed-transaction to solve it? Thanks in advance for any help.

Yes, it is possible, but you have to make sure that ANY call to EJB 3 through that method has the same requirements:
EJB 1 - Transaction = Required
EJB 2 - Transaction = Required
EJB 3 - Transaction = Requires New (starts a new transaction, "holds" the one from 1 & 2)
EJB 4 - Transaction = Requires
EJB 5 - Transaction = Requires

Similar Messages

  • Transaction handling in EJBs

    i dont know ejb�s handle transaction.
    any sugesstions??????
    sorry my english, ciao

    http://www.google.com/search?hl=en&q=EJB+transaction+handling
    Especially look at this one:
    http://www.kevinboone.com/ejb-transactions.html

  • Exception generated during defered local transaction handling

    Hi All,
    We are using data direct connect 3.3 driver with MS SQL Server 7 on WebSphere 4.0. We are getting the exception "Exception generated during defered local transaction handling". Anyone encountered similar problem?> please let me know the solution. I am pasting the stack trace here.
    Thanks in advance.
    Regards,
    Girish
    [7/29/05 9:19:31:210 EDT] 37c1f1 SystemOut U 2005-07-29 09:19:31,177 [Servlet.Engine.Transports:10] ERROR com.xyz.nuuw.bus.dao.JDBCWrapper -livdsqa11122643171177
    java.sql.SQLException: [IBM][SQLServer JDBC Driver]Exception generated during defered local transaction handling. See next exception via SQLException.getNextException for details.
    at com.ibm.websphere.jdbc.base.BaseExceptions.createException(Unknown Source)
    at com.ibm.websphere.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.ibm.websphere.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.ibm.websphere.jdbc.base.BaseConnection.transactionableWorkStarting(Unknown Source)
    at com.ibm.websphere.jdbc.base.BaseStatement.commonExecute(Unknown Source)
    at com.ibm.websphere.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
    at com.ibm.websphere.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
    at com.ibm.websphere.jdbcx.base.BasePreparedStatementWrapper.executeQuery(Unknown Source)
    at com.ibm.ejs.cm.cache.CachedStatement.executeQuery(CachedStatement.java:312)
    at com.ibm.ejs.cm.proxy.StatementProxy.executeQueryCommon(StatementProxy.java:410)
    at com.ibm.ejs.cm.proxy.PreparedStatementProxy.executeQuery(PreparedStatementProxy.java:53)
    at com.xyz.nuuw.bus.dao.JDBCWrapper.getdata(JDBCWrapper.java:164)
    at com.xyz.nuuw.bus.dao.AccountSetupPH.getKeyID(AccountSetupPH.java:445)
    at com.xyz.nuuw.bus.bo.AccountSetupBO.getKeyID(AccountSetupBO.java:50)
    at com.xyz.nuuw.accountSetup.bus.ejb.AccountSetupSBBean.getKeyID(AccountSetupSBBean.java:85)
    at com.xyz.nuuw.accountSetup.bus.ejb.EJSRemoteStatelessAccountSetupSB_14ea1086.getKeyID(EJSRemoteStatelessAccountSetupSB_14ea1086.java:99)
    at com.xyz.nuuw.accountSetup.bus.ejb._AccountSetupSB_Stub.getKeyID(_AccountSetupSB_Stub.java:310)
    at com.xyz.nuuw.bus.AccountSetupBD.getKeyID(AccountSetupBD.java:73)

    I am currently working with IBM on a similar problem with WAS 5.1 and SQL Server 2000. The SQLException has a nested exception that can be retrieved using the getNextException() method. This will give you some more information as to what is causing the problem. Ours seems to be triggered by a dropped connection at the SQL end. normally WAS will recover from that gracefully, but in our situation it is not.
    Doug

  • Is ths Transaction Handling Write or Wrong ?

    I little bit hesitate about Transaction handling in my application. I want to add data to database, before do this following steps should happen
    # add data to account table
    # update account serial which locate another table
    # add data to monthtrm table
    # update monthtrm serial which locate another table
    In order to success this step I used container manager transaction below show that code
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
        public void addNewFixDepositAccount(Account account, String cusId, String branchCode, int newSerial, String userCode) {
            try {
              //add data to account table
              this.create(account);
                    //update the SystemParameter table with new saving serial
                    systemParameterFacade.setFdSerial(newSerial);
              //add data to monthtrn tabel     
              monthTrnFacade.create(monthTrn);
                    //update the SystemParameter table with new monthtrn serial
                    systemParameterFacade.setTrnSerial(nxtTranSerial);
         } catch (CopException e) {
         if (e.getStackTrace().length > 0) {
                    System.out.println("Custom Massage :-" + e.getMessage());
                    System.out.println("Called Class :-" + e.getCalledClass());
                    System.out.println("Exception Handling Class :- " + getClass());
                    System.out.println("Calling Method :-" + Thread.currentThread().getStackTrace()[1].getMethodName());
                    System.out.println("Called Method :-" + e.getCalledMethod());
                    System.out.println("Exception Line Number :-" + e.getStackTrace()[21].getLineNumber());
                    System.out.println("Date and Time :- " + e.getDateTime());
                    System.out.println("Exception Type :-" + e.getCause().toString());
                } else {
                    System.out.println("Custom Massage :-" + e.getMessage());
                    System.out.println("Called Class :-" + e.getCalledClass());
                    System.out.println("Exception Handling Class :- " + getClass());
                    System.out.println("Calling Method :-" + Thread.currentThread().getStackTrace()[1].getMethodName());
                    System.out.println("Called Method :-" + e.getCalledMethod());
                    System.out.println("Date and Time :- " + e.getDateTime());
                    System.out.println("Exception Type :-" + e.getCause().toString());
    }   Add data to account
        public void create(Account account) throws CopException {
            try {
                em.persist(account);
                em.flush();
                em.clear();
            } catch (Exception e) {
                context.setRollbackOnly();
                throw new CopException("Can't Add Account", e, getClass().toString(), Thread.currentThread().getStackTrace()[1].getMethodName());
      Add data to monthtrn
        public void create(MonthTrn monthTrn) throws CopException {
            try {
                em.persist(monthTrn);
                em.flush();
                em.clear();
            } catch (Exception e) {
                context.setRollbackOnly();
                throw new CopException("Can't Add MonthTrm", e ,getClass().toString(),Thread.currentThread().getStackTrace()[1].getMethodName());
    Update Account serial
        public void setFdSerial(int fdSerial) throws CopException {
            try {
                Query query = em.createQuery("UPDATE SystemParameter s SET s.fdSerial = :fdSerial");
                query.setParameter("fdSerial", fdSerial);
                query.executeUpdate();
                em.flush();
            } catch (Exception e) {
                context.setRollbackOnly();
                throw new CopException("Can't Update FD Serial", e, getClass().toString(), Thread.currentThread().getStackTrace()[1].getMethodName());
       Update Trnserial
        public void setTrnSerial(int trnSerial) throws CopException {
            try {
                System.out.println("Trn Serial : " + trnSerial);
                Query query = em.createQuery("UPDATE SystemParameter s SET s.trnSerial = :trnSerial");
                query.setParameter("trnSerial", trnSerial);
                int result = query.executeUpdate();
                System.out.println("Number of updated records in transaction Serial :- " + result);
            } catch (Exception e) {
                context.setRollbackOnly();
                throw new CopException("Can't Update Trn Serial", e, getClass().toString(), Thread.currentThread().getStackTrace()[1].getMethodName());
        }Exception Class
    package bank.exception;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import javax.ejb.ApplicationException;
    * @author dinesh
    @ApplicationException(rollback = true)
    public class CopException extends Exception {
        private String calledClass;
        private String calledMethod;
        public String getDateTime() {
            DateFormat dateFormat = new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss");
            java.util.Date date = new java.util.Date();
            return dateFormat.format(date);
        public CopException(String string, Exception ae, String className, String methodName) {
            super(string, ae);
            this.getDateTime();
            this.setCalledClass(className);
            this.setCalledMethod(methodName);
        public String getCalledClass() {
            return calledClass;
        public void setCalledClass(String calledClass) {
            this.calledClass = calledClass;
        public String getCalledMethod() {
            return calledMethod;
        public void setCalledMethod(String calledMethod) {
            this.calledMethod = calledMethod;
    Is this way correctly handle Transaction? If I wrong please give me you're precious advice to improve my program efficiency, please give some comments

    Sounds fine to me. If you have duplicated yourself too much, you can refactor the model later to remove duplication. If there is no duplication, then separate models was the right choice.

  • Nested Transaction and J2EE

    Hi,
    I have a question about how J2EE Application server (WAS4.x/5.x) follows the spec for Nested transaction. In a J2EE tutorial at one place it says
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction4.html
    following :
    A JTA transaction is controlled by the J2EE transaction manager. You may want to use a JTA transaction because it can span updates to multiple databases from different vendors. A particular DBMS's transaction manager may not work with heterogeneous databases. However, the J2EE transaction manager does have one limitation--it does not support nested transactions. In other words, it cannot start a transaction for an instance until the previous transaction has ended.
    It means I cannot start another transaction while the first one is not completed.
    CASE 1:
    My statefull session bean has method a() and method b().
    Method a() calls Method b().
    I have started userTransaction in Method a() and before commiting
    it I have started another transaction in method b(). like
    Method a() {
    Statrs TX
    calls b()
    Commits TX
    Method b() {
    Starts TX
    Commits TX
    CASE 2:
    What if I use Declarative TX
    and specify method a() requires new
    and method b() also requires new.
    Where, method b() is invoked by method a() in a statefull session
    bean.
    Thanks in advance.

    I had i similar problem and solved it in th following way.
    My first attempt was to call an atomic method which has the transaction attribute "RequiresNew" from a complex method with the transaction attribute "Required". Both methods where located in the same Session EJB class. If the code inside the atomic method fails by an exception, the exception will be catched and ctx.setRollbackOnly( ) be called in the catch block. This does NOT work! So I start reading a lot in the net and in books. I foud that J2EE does not support nested transactions. So that was a shoot in my foot! :-(
    Frustated I went home from work and in the evening I remember some words from Adam Bien, the author of J2EE Patterns. He said that you can build something like nested transactions if you use an additional EJB layer. He said that in the context of a SessionFacade and a set of EntityBeans. But he also said that this will also work with layers of SessionBeans.
    At the next day, I build the addional Session EJB and moved all atomic methods in that Session EJB. So the situation is now like this. My ComplexEJB holds method which define a more complex business process. Each of this processes call a lot of atomic methods from the Atomic EJB. In my case it�s not neccesary that all of this atomic methods have to succeed. OK, the methods with transaction attribute "Required" will proceed as much atomic methods with transaction attribute "RequiresNew" as possible! But if a "hard" Exception occurs the whole transaction is rolled back.
    This works very good for our needs!
    public class ComplexEJB implements SessionBean
        public Collection complexMethod1( Parameter param ) throws BusinessException
         try
                service = this.getAtomicServiceLocal( );
                service.atomicMethod1( param.getSubparam1( ) );
                        service.atomicMethod3( param.getSubparam3( ) );
                        service.atomicMethod1( param.getSubparamN( ) );
                        service.atomicMethod1( param.getSubparam1( ) );
                          catch( "hard" exception like Nullpointer i.e. )
                       //if an "hard" Exception occur rollback the whole transaction
                       ctx.setRollbackOnly( );
        public Collection complexMethodN( Parameter param ) throws BusinessException
         try
            service = this.getAtomicServiceLocal( );
            service.atomicMethod1( param.getSubparam1( ) );
                    service.atomicMethod3( param.getSubparam3( ) );
                    service.atomicMethod1( param.getSubparamN( ) );
                    service.atomicMethod1( param.getSubparam1( ) );
                         catch( "" hard exception like Nullpointer i.e. )
                     //if an "hard" Exception occur rollback the whole transaction
                     ctx.setRollbackOnly( );
    public class AtomicEJB implements SessionBean
        public Collection atomicMethod1( Parameter param ) throws BusinessAtomicException
                try
              //The call to a service i.e. access to database
         catch ( DatabseException cbex )
              ctx.setRollbackOnly(  );
         finally
              //release database connection i.e.
        public Collection atomicMethodN( Parameter param ) throws BusinessAtomicException
                try
              //The call to a service i.e. access to database
         catch ( DatabseException cbex )
              ctx.setRollbackOnly(  );
         finally
              //release database connection i.e.

  • Nested Transaction required... workaround?

    We have a situation that would best be coded with a nested transaction. As J2EE does not support these, are there standard ways to work around this sort of problem? Our situation is:
    1. Get a msg from JMS
    2. Process the message- involves inserting data into multiple tables...
    - If successful- commit msg from queue; commit data.
    - If unsuccessful- move msg to error queue; rollback ALL table inserts.
    Our current proposed workaround involves around 4 sequential transactions, use of staging tables, etc. etc. I feel there ought to be a cleaner solution.
    Ideas most welcome...
    Gavin Griffith-Jones

    Hi Gavin,
    You can do the following:
    - If you are not using an EJB, then start a transaction using the Java Transaction API (JTA).
    - When obtaining a connection to the database for the inserts, use a transactional datasource.
    - Start the transaction within a try/catch block and perform the inserts sequentially. If an exception is thrown, rollback the transaction with the UserTransaction rollback method. This will rollback all the insertions.
    - If no exceptions were thrown, then call the tran.commit() method in the try/catch block.
    Since there is a lot to do, contain your code in different classes for a cleaner solution.
    Best of luck,
    Rich

  • Transaction Handling - JDBC Receiver Adapter - Multiple SP Calls

    Hello,
    I have the following scenario:
    I send an XML-SQL structure with multiple statment elements (each of them calling a different stored procedure). A stored procedure raises an error back to the JDBC Receiver Adapter in case of error.
    Is it possible to have transaction handling in the JDBC Receiver to ensure:
    - Commit only after ALL stored procedures where succesful (no error risen during calls)
    - Rollback of ALL already called stored procedures in case an error has been risen
    How can I implement these requirements in the JDBC Receiver Adapter?

    One more comment, I have found the following info for JDBC Drivers:
    <i> "JDBC driver's default is to autocommit, meaning that the result of every SQL statement is permanent as soon as it is executed. This is why the course hasn't had to be concerned with transactions so far, and is perfectly acceptable in many cases."</i>
    So I think that each SP-Call is automatically commited in case autocommit on JDBC Driver Level is set to "true". Does anyone know where I can change these settings? Directly on JDBC Receiver Adapter or do I have to go to Visual Admin for those changes?

  • Transaction Handling in Forte

    I have a serious problem with Forte Transaction handling.
    If a transaction gets aborted through the statement Transaction.Abort
    (not because of a database exception), looks like some resources/locks
    are not released as a result of which if the current screen is closed,
    Forte does not allow the screen to be re-opened. It gives some vague
    error like 'Incorrect syntax near '.'
    Following is the piece of code. I would appreciate it if someone could
    give me a solution.
    Thanks,
    Begin Transaction
    commitFlag = true;
    Function1(commitFlag);
    if commitflag
    Function2(commitFlag);
    end if;
    if NOT commitflag
    ex :UserDefinedException = new;
    Transaction.Abort(ex,true);
    end if;
    Exception
    When ex : UserDefinedException do
    End Transaction;
    Function1(commitFlag In/Out)
    SQL Select some_flg from some_tab;
    If some_flag = 'A'
    ex : UserDefinedException = new;
    commitFlag = false;
    raise ex;
    end if;
    update some_tab with some_flg;
    Exception
    when ex:UserDefinedException do
    Function2(commitFlag In/Out)
    SQL Select some_flg from another_tab;
    If some_flag = 'A'
    ex : UserDefinedException = new;
    commitFlag = false;
    raise ex;
    end if;
    update another_tab with some_flg;
    Exception
    when ex : UserDefinedException do
    }

    Transaction processing in FORTE is not straight forward. The wrong order
    of statements may break your code. In your example I can suggest to
    remove exceptions processing blocks from methods Function1 and
    Function2. If transaction aborts in Function1, Function2 won't be
    executed, so you don't need to use your commitFlag. You should process
    an exception what is generated by transaction.abort in the same method
    where transaction started or higher, otherwise it does work properly.
    Hope it helps.
    Igor Teselko.
    RAO Meena wrote:
    >
    I have a serious problem with Forte Transaction handling.
    If a transaction gets aborted through the statement Transaction.Abort
    (not because of a database exception), looks like some resources/locks
    are not released as a result of which if the current screen is closed,
    Forte does not allow the screen to be re-opened. It gives some vague
    error like 'Incorrect syntax near '.'
    Following is the piece of code. I would appreciate it if someone could
    give me a solution.
    Thanks,
    Begin Transaction
    commitFlag = true;
    Function1(commitFlag);
    if commitflag
    Function2(commitFlag);
    end if;
    if NOT commitflag
    ex :UserDefinedException = new;
    Transaction.Abort(ex,true);
    end if;
    Exception
    When ex : UserDefinedException do
    End Transaction;
    Function1(commitFlag In/Out)
    SQL Select some_flg from some_tab;
    If some_flag = 'A'
    ex : UserDefinedException = new;
    commitFlag = false;
    raise ex;
    end if;
    update some_tab with some_flg;
    Exception
    when ex:UserDefinedException do
    Function2(commitFlag In/Out)
    SQL Select some_flg from another_tab;
    If some_flag = 'A'
    ex : UserDefinedException = new;
    commitFlag = false;
    raise ex;
    end if;
    update another_tab with some_flg;
    Exception
    when ex : UserDefinedException do

  • Removing the entity object commit from transaction handler

    Hi,
    The business reuirement of the OAFWK page developed by us is as explained below:
    The basic functionality is of updating the attributes of items attached to the change order.
    The UI components displayed in the page(Item attribute changes region) are built based on the properties of the item attributes as LOV,poplist,textbox etc..
    The dynamic VO mapped to these UI components is based on a standard entity object.
    User operation:Select any attribute group and click on Go button.The Item attributes of the attribute group are displayed.Enter values in the Item Attributes and click on Apply button of the region.(changes made in the attributes related to the attribute group are committed to the database using
    &lt;Root AM&gt;.getTransaction.commit()).
    Now we have two such regions in the same page.
    On top of the page the item attributes of _{color:#800000}&lt;Item Type X&gt;{color}_ are displayed.
    Down the page, the item attributes of {color:#0000ff}&lt;_Item Type Y_&gt;{color} are displayed.
    In few special cases i.e for few item attributes, on click of Apply button for {color:#0000ff}_Item Y_{color} , the attributes of {color:#800000}I_tem X_{color} are to be updated by calling a PLSQL API.When Apply button in the Item attributes of _{color:#0000ff}Item Type Y{color}_ is clicked,the execution of controllers is :
    1.Controllers of Item attribute changes region of {color:#800000}&lt;Item Type X&gt; {color}The dynamic VO is built for the item attributes of Item Type X
    2.Controllers of the Item attribute changes region of {color:#0000ff}Item Type Y{color} The dynamic VO is built for the item attributes of Item Type Y.In the last controller of the hierarchy, the PLSQL API call is included(by invoking the method in AM) to update few attribute values of {color:#800000}Item Type X and finally &lt;Root AM&gt;.getTransaction().commit().
    Problem : The updated values by PLSQL API for {color:#800000}_Item Type X_{color} are not reflected in the database but indeed the values entered by user for {color:#800000}_Item Type X_{color} in the top of the page are committed(The Apply button for {color:#800000}_Item Type X_{color} is not clicked).
    _&gt;&gt;Please note that the dynamic VOs of both the Item Types are built on the same standard Entity Object_
    I am struggling to know the reason why the values updated by PLSQL API are overwrittem by the values in the entity object even though the PLSQL API is called in the last controller of execution.Please let me know if there is any OAFWK constraint.
    I tried the approach of removing the commit of the dynamic VO built in the region of {color:#800000}_Item Type X&gt;_ {color}{color:#000000}I fetched the entity implementation of the dynamic VO row and used removeandRetain(),revert().But this approach failed.I am referring to the jdevdoc for the built-in methods.
    {color}
    Now the requirement is the latest values updated by API (for {color:#800000}_Item Type X_{color}) should be committed in the database but not the values updated by the entity object for {color:#800000}_Item Type X_ {color}{color:#000000}in the item attributes region{color}.
    There should a single commit for the entire transaction of the page.
    Is there any chance to remove the commit of item attributes of {color:#800000}_Item X_{color} alone from the transaction handler?There are few methods in oracle.jbo.server.EntityImpl class such as doRemoveFromTransactionManager().But these methods are either protected or private.So classes of other packages cannot access them.
    So pelase suggest me if there is a workaround for this scenario.
    Thanks and Regards,
    Kiran
    Edited by: Kiran.A on Sep 20, 2008 3:34 AM

    Hi Sumit,
    Yes I agree on that front that updating the same record through PLSQL and EO is not the right approach.
    But the business requirement is as such and we do not have any workaround for this.
    Please let me know if there is any way to avoid the EO commit by removing from transaction listener.
    Regards,
    Kiran

  • Transaction Handling in webservice based partnerlink

    What is the transaction handling mechanism for parnerlink which calls webservice (not native BPEL/ESB)?
    REgards
    priyadarshi

    It is SDO using I think
    It should be not SOAP action, because it is not support transactions

  • Transaction handling in Siebel

    Hi
    Can I implement transaction handling in Siebel? If yes, how can I implement it?
    Thanks
    Gana

    This pdf give some background on transactions and error handling within esb 10g.
    http://www.oracle.com/technology/products/integration/esb/files/esb-transactions-errorhandling.pdf
    not very detailed

  • Transaction Handling across Procedures

    In the ODI Best Practice Guide for Data Warehouses I came across the following (page 100):
    "ODI procedures include an advanced mechanism for transaction handling across multiple steps or even multiple procedures."
    It states that transaction handling can occur across multiple procedures. I could not get this to work.
    I created a procedure with just one step that inserts into a table. In the step I have set the Transaction dropdown to Transaction 0 and the Commit dropdown to No Commit. However, when I execute the procedure the insert is committed as we terminate the session.
    Any ideas how this commit can be prevented?

    ok, I figured out that parameters to the JDBC driver can be specified at the properties tab of the data server.
    So I presume this will be autocommit = false or sth. similar
    I still have to try this out.

  • Osb 11g transaction handling

    Hi,
    I have a problem with transaction handling in OSB 11g. When I add a report action, error messages disappear.
    The process is the following:
    jms-queue -> proxy-service ->business-service ->EBS webservice.
    In the proxy-service I add an error-handler at node-level. In this error-handler I log the error-message in the server log. In the regular process there is a request and response-pipeline.
    When I add a message on the queue and when the response from EBS is negative, the message is placed on a errorqueue. That's ok.
    When I add a report-action to the error-handler and then I put another message on the queue, the message is disappeared. It is not on the error-queue and not on the normal queue. When I look in the database there is an extra row added.
    I use the default datasource(wlsbjmsrpDataSource).
    I found for example this blog: http://biemond.blogspot.nl/2010/11/global-transactions-and-quality-of.html ; but I can't find an example with writing to a database and a rollback to an errorqueue. The report-action needs it's own transaction.
    In the weblogic console -> datasources -> transaction I unchecked "Keep Connection After Local Transaction" but that didn't work.
    What kind of options is possible?
    Herman

    I cant believe i was answered by the famous Anuj!.
    You were correct. The weird thing, is that in publish actions the QoS is not propagated onto the target of that Publish per se.
    We say this, becouse the Local PS has the Transaction Required = True, ergo the QoS is Exactly Once all along its message flow. It also propagates in the service callout´s and Route Node´s. Thats why we, trying to avoid redundance, didnt specified it in the publish action.
    Thank you very much.
    Regards.
    Mario.

  • Web Service transaction handling

    Hello,
    Is it possible in SAP NW to execute several calls to Web Services in one LUW (logical unit of work)? And be able to commit or rollback?
    Where can i find information about Web Service transaction handling in SAP?
    Best regards
    Ute

    I haven't found any official info on it, but my simple testing (mainly via ST05) indicates that you should be able to call multiple web services within a single LUW -  there seems to be no implicit "commit work" issued by the framework (unlike remote RFC calls).
    Jonathan

  • Javax.ejb.EJBException: Transaction aborted

    Hello everyone, I am new in javaEE6. When i try to develop and simple example i meet this error but i can't find which code line cause it. I use JSF EJB3.1 EclipseLink JPA 2.0 in Glassfish v3 and developed in Netbean6.8. Here is my Stack trace .
    Caused by: javax.ejb.EJBException: Transaction aborted
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4997)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
         at $Proxy158.createUsers(Unknown Source)
         at home.tuan.bussiness.__EJB31_Generated__UsersEJB__Intf____Bean__.createUsers(Unknown Source)
         at home.tuan.controller.UsersController.doCreateUser(UsersController.java:40)
         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:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
         at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
         at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
         ... 32 more
    Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
         at com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:450)
         at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:837)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4991)
         ... 48 more
    Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "." at line 1, column 29.
    Error Code: -1
    Call: INSERT INTO ChatDatabase.dbo.Users (UserName, Pass) VALUES (?, ?)
         bind => [er, w]
    Query: InsertObjectQuery(home.tuan.model.Users@825299)My Entity is:
    package home.tuan.model;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.Table;
    * @author minhtuan
    @Entity
    @Table(name = "Users", catalog = "ChatDatabase", schema = "dbo")
    public class Users implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id  
        @Column(name = "UserName")
        private String userName;
        @Column(name = "Pass")
        private String pass;
        public Users() {
        public Users(String userName, String pass) {
            this.userName = userName;
            this.pass = pass;
        public String getUserName() {
            return userName;
        public void setUserName(String userName) {
            this.userName = userName;
        public String getPass() {
            return pass;
        public void setPass(String pass) {
            this.pass = pass;
    }My session bean is:
    package home.tuan.bussiness;
    import home.tuan.model.Users;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    * @author minhtuan
    @Stateless
    public class UsersEJB {
      @PersistenceContext(unitName="MavenTestPU")
      private EntityManager em ;
      public Users createUsers(Users newUser){
          em.persist(newUser);
          return newUser;
    }My controller class is:
    package home.tuan.controller;
    import home.tuan.bussiness.UsersEJB;
    import home.tuan.model.Users;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.EJB;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.RequestScoped;
    import javax.persistence.EntityTransaction;
    import javax.persistence.Persistence;
    import javax.transaction.UserTransaction;
    * @author minhtuan
    @ManagedBean(name="UsersController")
    @RequestScoped
    public class UsersController {
        /** Creates a new instance of UsersController */
        @EJB
        UsersEJB userEJB;
        Users newUser = new Users();
        List<Users> listUsers = new ArrayList<Users>();
        public String doNewUser(){
            return "index.jsp";
        public String doCreateUser(){
            System.out.println("Den day rui");
            System.out.println(newUser.getUserName());
            System.out.println(newUser.getPass());
            newUser = userEJB.createUsers(newUser);
            return "index.jsp";
        public List<Users> getListUsers() {
            return listUsers;
        public void setListUsers(List<Users> listUsers) {
            this.listUsers = listUsers;
        public Users getNewUser() {
            return newUser;
        public void setNewUser(Users newUser) {
            this.newUser = newUser;
    }And my persistence.xml is:
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="MavenTestPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>home.tuan.model.Users</class>
        <properties>
            <!--
          <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
          <property name="javax.persistence.jdbc.password" value="12345"/>
          <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
          <property name="javax.persistence.jdbc.user" value="sa"/>
          -->
           <property name="eclipselink.target-database" value="SQLSERVER"/>
           <property name="eclipselink.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
           <property name="eclipselink.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
                <!--<property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>-->
                <!--<property name="eclipselink.jdbc.url" value="jdbc:derby:chapter10DB;create=true"/>-->
           <property name="eclipselink.jdbc.user" value="sa"/>
           <property name="eclipselink.jdbc.password" value="12345"/>
                <!--property name="eclipselink.ddl-generation" value="update"/-->
                <!--property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
           <property name="eclipselink.logging.level" value="INFO"/>
        </properties>
      </persistence-unit>
    </persistence>Thanks in advance
    Edited by: ActiveDean on Dec 24, 2009 4:38 PM

    You need to step through a debugger and find the source of your problem as something is clearly going wrong and causing the transaction to roll back. That is all that message tells us.
    m

Maybe you are looking for