How to use Transaction in Stateless SessionBean?

I want to use a transaction in a stateless sessionbean.Here is the code I am using:
public void createQuestion(QuestionModel questionModel,Collection outcomeList) throws Exception{
UserTransaction ut=getUserTransaction();
try{
QuestionHome qHome=EJBUtil.getQuestionHome();
QuestionOutcomeHome qoHome=EJBUtil.getQuestionOutcomeHome();
ut.begin();
QuestionRemote qr=qHome.create(questionModel.getName(),questionModel.getContent(),questionModel.getCreatorId());
Long id=qr.getQuestionModel().getId();
Iterator outcomes=outcomeList.iterator();
while(outcomes.hasNext()){
QuestionOutcomeModel qom=(QuestionOutcomeModel)outcomes.next();
QuestionOutcomeRemote qor=qoHome.create(id,qom.getValue(),qom.getFeedBack());
ut.commit();
}catch(Exception e){
ut.rollback();
throw new Exception(e);
private UserTransaction getUserTransaction() throws NamingException{
UserTransaction ut=null;
try{
InitialContext ic = new InitialContext();
ut = (UserTransaction) ic.lookup("UserTransaction");
} catch (NamingException ne) {
throw new EJBException(ne);
return ut;
And In the entity bean,I define a XADatasource:
private Connection getXADBConnection() throws SQLException {
Connection connection;
try {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)
ic.lookup("java:/MSSQLXaDS");
connection = ds.getConnection();
} catch (NamingException ne) {
throw new EJBException(ne);
} catch (SQLException se) {
throw new EJBException(se);
return connection;
When I run the code, it throws the following Exception:
java.lang.Exception: java.lang.reflect.UndeclaredThrowableException
     at com.dynasty.testing.testcontent.control.TestContentSB.createQuestion(TestContentSB.java:239)
     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:324)
     at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
     at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
     at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
     at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
     at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
     at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
     at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
     at org.jboss.ejb.Container.invoke(Container.java:712)
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
     at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
     at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
     at sun.rmi.transport.Transport$1.run(Transport.java:148)
     at java.security.AccessController.doPrivileged(Native Method)
     at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
     at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
     at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
     at java.lang.Thread.run(Thread.java:536)
     at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
     at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
     at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
     at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
     at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:138)
     at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
     at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
     at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
     at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:111)
     at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
     at $Proxy1.createQuestion(Unknown Source)
     at com.dynasty.testing.test.TestContentSBTestClient1.main(TestContentSBTestClient1.java:466)
Caused by: java.lang.reflect.UndeclaredThrowableException
     at $Proxy196.create(Unknown Source)
     at com.dynasty.testing.testcontent.control.TestContentSB.createQuestion(TestContentSB.java:229)
     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:324)
     at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
     at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
     at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
     at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
     at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
     at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
     at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
     at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
     at org.jboss.ejb.Container.invoke(Container.java:712)
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
     at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
     at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
     at sun.rmi.transport.Transport$1.run(Transport.java:148)
     at java.security.AccessController.doPrivileged(Native Method)
     at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
     at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
     at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
     at java.lang.Thread.run(Thread.java:536)
Caused by: javax.resource.ResourceException: associateConnection not supported
     at org.jboss.resource.adapter.jdbc.BaseManagedConnection.associateConnection(BaseManagedConnection.java:91)
     at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnect(BaseConnectionManager2.java:594)
     at org.jboss.resource.connectionmanager.CachedConnectionManager.reconnect(CachedConnectionManager.java:344)
     at org.jboss.resource.connectionmanager.CachedConnectionManager.pushMetaAwareObject(CachedConnectionManager.java:140)
     at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:183)
     at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:90)
     at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
     at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
     at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:59)
     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111)
     at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
     at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
     at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
     at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
     at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
     at org.jboss.ejb.Container.invoke(Container.java:730)
     at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
     at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
     at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
     at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
     at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
     at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:198)
     at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
     ... 28 more
What's wrong with my code?Can anyone hlep me?Thanks

Susan,
I am replying because I think we are in the same class at Wake Tech (Saturday morning with Jeff Griemann), trying to get past the same problem. After many frustrating hours, I have the answer. Reinstall Tomcat in a directory with NO SPACES in the directory name. That it!
Dennis

Similar Messages

  • How to use transaction SOST & SCOT for checking Email performance ?

    How to use transaction SOST & SCOT for checking Email performance ?
    what exactly as CRM Functional we have to do in above transaction .
    Please guide me . what is significance of these transaction ?
    Regards,
    Anup Reche

    Hi Anup,
    Transaction SOST is used to view the status of the sent mails from SAP.
    You cna filter the mails sent by a particular user, on a specified date range and time.
    You can list the mails in the status Waiting, Error, Sent or Transmitted.
    You can also go to the log of the mail and see its details and can also open the mail sent by the user.
    You can add the filters as per your requirement.
    Transaction SCOT is SAP Connect used to make connections from SAP to external applications.
    You cna configure sending of external mails in SCOT by specifying the SMTP host and port to be used.
    Hope this gives you a basic idea of the 2 transactions.
    Regards,
    Saumya

  • How to use transaction FPOP

    Hi,  All,
    I am trying to do delta upload for FI-CA business partner items 0FC_BP_ITEMS. I see there is a documentation say "Before you start the delta extraction, you should update the delta queue for this DataSource in the plugged-in OLTP system using transaction FPOP.". After my initial load, I made a new posting. And then I ran FPOP, and then I run delta update. But I am told "No new data since the last delta update". So seems delta did not get my new posting. Is there anybody can give some advice, or tell me how to use FPOP? I am not sure how to create the Variant in FPOP. Thanks a lot!
    Meiying

    HI ,
    Steps for FPOP
    1. Under General Selection tab input Date ID and Identification. - > Combination of this must be Unique.
    2.Steps to create Variant - >Under technical settings tab , select tab for variant maintenance -> press F7 to create a new variant  -> give a variant name -> Select number of intervals and give number value as 999 and execute.
    New Variant is created.
    3.Use the new variant, save all settings and "Schedule the program run".
    4.Click on refresh to track the status of the program run.
    5.Goto RSA7 and check for the Delta Queue - new values will be populated.

  • How to use Transaction Variant

    Hi all,
    Pls tell me how to us Transacton Variant step by step. I have just created Transaction Variant from TCode PB10 but I don't know how to use it.
    I want to change some fields on PB10 screen.
    Thanks so much for your supports,
    Quang,

    Hi,
    See if this link helps.
    http://www.mhn-consulting.com/Security/transactionvariants.htm
    Creating a variant transaction is a better option. If PB10 now works like the modified screen try to deactivate the transaction and create and variant transaction.
    Regards,
    Soujanya.

  • How to use Transaction RATRACE0N

    Hello All,
    If i am using transaction RATRACE0N in my system i am getting an following message
    "It is not possible to display the depreciation calculation
    Message no. AY818
    Diagnosis
    Information on the calculation of depreciation is not available on the asset entered, because depreciation calculation could not be carried out for it. A possible reason for this is that the asset is already deactivated.
    Procedure
    Check the asset."
    I have checked in the asset explorer transaction  AW01N . All the required asset are working fine and displaying the calculations as required.
    Can any one help me how to solve the problem with transaction RATRACE0N. Is there any pre-requisites to run the transaction RATRACE0N?
    Thanks,
    Feroz.

    Hello Markus,
    Thanks for you comments.
    I have added the report _RATRACE0N_ in Maintain report section and called the report from Call up report in transaction AW01N.
    Still i am getting the above specifed message.
    Is there any settings or configurations need to be maintained to run this report RATRACE0N?
    Thanks,
    Feroz.

  • ALE:How to use transaction WE12?

    Hi,
    How to use the transaction WE12?
    T-code :WEDI->Test->WE12
    Thanks and Regars,
    Madhu

    Dear Madhu,
    It copies the data file in application server of source sysem to destination system and triggers inbound program for updating the data to databse.
    Regards,
    Prasanth

  • How to use transaction in jsp in CQ5.5

    Hello,
    i'm playing around with transactions Jackrabbit should be capable of
    I didn't find any resource to that specific topic.
    Here's my code so far, but it isn't working properly...
    final SlingRepository repository = sling.getService(SlingRepository.class);
    Session session = repository.loginAdministrative(null);
    UserTransaction utx = sling.getService(UserTransaction.class);
    utx.begin();
    out.println(utx.getStatus());
    Node node = session.getNode("/path/to/a/content");
    node.setProperty("a","property");
    session.save();
    out.println(utx.getStatus());
    utx.rollback();
    session.logout();
    Expected result: The Property "a" is not appended to the node because Transaction was rolled back
    Achieved result so far: The property is saved to the node.
    What am i doing wrong?
    What is the preferred way to use transaction?
    Background: we are doing some asset operations in user profile node that take some time. It seems that the reverse replication launcher starts in between the process and breaks the replication process every now and then
    Thanks for advice
    Marc

    I'm not very familiar with ODP .NET so I'm not sure what OracleTransactions is or what it actually does. TTClasses implements the normal TimesTen (ANSI) transaction model:
    1. Transactions are specific to a database connection
    2. You are always in a transaction except (a) immediately after you have connected and (b) immediately after a commit or rollback
    3. The first database operation (including SELECT) executed after (a) or (b) above starts a transaction (there is no explicit 'begin work' operation)
    4. A transaction is completed by either committing (call the TTConnection.commit() method or execute the COMMIT [WORK] SQL statement) or by rolling bacl (call the TTConnection.rollback() method or execute the ROLLBACK [WORK] SQL statement).
    Does this answer the question? If not, please provide more details on what information you are seeking.
    Thanks,
    Chris

  • How to use transaction code j2ic

    DEAR ALL,
    How can i use to file the service tax return through t.code j2ic.

    Hi Mukesh,
    This is Vendor Mass maintenance transaction.
    Following links should help you know more :
    Mass maintenance: Vendors
    Transaction XK99
    Problem with XK99 Mass Load Maintenance
    XK99 Vendor mass maintenance
    Hope this helps!
    Thanks,
    Ravi

  • How to use transactions

    Hi,
        I am trying to implement transaction on an Objects. When I use Company.StartTransaction , my application becomes very slow. I want to know how it works? Does it lock the object? If it locks how to implment concurrent users transactions? How to avoid deadlock?
    Thanks & regards,
    Raj

    Hello
    transaction handling:
    - local transaction (single transaction)
    so basically each data manupilation (update, add) over a business objects using a transaction, called local transaction of the business object.
    Business Object means DI API objects, like Documents, BusinessPartners, Items, etc.
    Example: if you issue a sales invoice document, it writes many tables in the background in a single transaction.
    Dim oDoc as SAPbobsCOM.Documents
    Set oDoc = oCompany.GetBusinessObject(oInvoices)
    This not causes deadlocks, only wait locks on the object while the process is finish. It has automatic rollback procedure, and you can query the result (eg the transaction is commited or rolled back) by the return code of the transaction. if return code differs from 0 you have a rollback event, and the error. If return code is 0 the transaction is commited
    lRetCode = oDoc.Add()
    - global transaction
    This global transaction can be used when you load large amount of flow pending data, and if there is an error in the flow you must redo (rollback) all your operations in the transaction. It is overrides the single transactions
    you can start the transaction by
    oCompany.StartTransaction()
    if the job finished, then you can till decide you dismiss the operations (roll back) or accept the data (commit). operations with business objects in the flow can do automatic rollback before you commit your work you may inquery the transation status
    if (oCompany.Intransaction) then
      company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
    end if
    If is comfortable used with Try Catch End Try error handling.
    Example:
    you load Business Partners and sales orders into SAP B1. If your business partner import is fails, your sales order will defekt by missing the business partner. In this case you can use global transaction for each BP - Sales Order pair. some pseudo code:
    1.read BP's
    2. start loop over BP-s
    3. Add BP
    - if BP cannot be added, skip loop and take next BP (step 5)
    4. Add Sales Order
    - if Sales Order cannot be added, rollback transaction and goto step 5, In this case BP and sales order will be not added.
    5 look for next BP
    This can cause deadlock's in the system, so take care usage of this.
    regards
    János
    Edited by: Janos Nagy on Jan 3, 2012 4:13 PM

  • How to use Transaction code XK99

    Hi Experts
    I have to test T-code Xk99 Can you please guide me how can I execute the T-code it .
    I mean which field in the vendor master data i can update through this program and is there any document i can get on this issue

    Hi Mukesh,
    This is Vendor Mass maintenance transaction.
    Following links should help you know more :
    Mass maintenance: Vendors
    Transaction XK99
    Problem with XK99 Mass Load Maintenance
    XK99 Vendor mass maintenance
    Hope this helps!
    Thanks,
    Ravi

  • How to use transaction SWIA?

    Hello, i have a shopping cart with approver app1 and app2. i wish to replace app2 by app3 .how can i use SWIA to do this?

    Hi
    First find out the work Item from transcation  SWI1 entering Type = US and ID= User
    Select To Be processed by option and find out the work item
    Then, go to SWIA and enter the work item  and execute the transcation and you can forward that particular work item to any other user using forward work item button
    It will prompt a field to enter the new user id to whom the work item is to  be  Routed
    thanks

  • How to use transaction GGB0

    Dear all,
    Please explain step by step procedure to use the transaction GGB0.
    Regards,
    Amiya Shrivastava

    Hello Amiya,
    Take a look at help.sap.com.
    For more information on creating and maintaining validations, see "Financial Accounting -> Special Purpose Ledger -> Tools -> Maintain Validation/Substitution/Rules -> Maintain Validations"
    Regards,
    john.

  • How to use Transaction

    I'm trying to use Toplink Transaction.
    Here is an example:
    ClientSession clientSession = acquireClientSession();
    Employee employee = getNewEmployee();
    session.beginTransaction();
    session.writeObject(employee);
    session.commitTransaction();
    When I run it, I got an QueryException:
    EXCEPTION DESCRIPTION: Objects or the database cannot be changed through a ServerSession. All changes must be done through a ClientSession's UnitOfWork.
    The same object can be inserted using UnitOfWork, but failed using the transaction directly and my session is a ClientSession.
    Any suggestion?
    Thanks,
    Wei

    TopLink does not allow direct transaction control and modification of shared objects from the cache in the Server/Client session architecture. This architecture is intended for a multi-threaded client.
    The UnitOfWork allows for your multi-threaded client to benefit from a shared cache while isolated the transient changes until they have been successfully committed to the database. Without this your various client threads would see uncommitted changes from other clients.
    http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10313/undrstdg.htm#1110428
    http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10313/xactions.htm#1138782
    Doug

  • How to use transaction OKB9

    Dear all, do you know if it is possible to execute the transaction OKB9 having the client parameter set to 'not modifiable' status?
    Regards
    Luca

    Luca,
    If client parameter is set to non modifiable, it simply means, you can not change any thing or create new. Best is that you follow the defined option by making the changes in development box and transport the same to production via QA or as per the system landscape.
    Regards
    Bharat

  • Using transaction DB02

    Hi Experts,
    How can get table lists of all infocubes  (using DB02 transaction) which have the largest in master data?
    Please give step by step how to use transaction DB02 to get list of table names of all infocubes.
    Thnaks!!
    Rohan

    Hi Rohan,
    1.To see the disk space used from an InfoCube you should see TCode DB02 and should sum all the involved tables (Detailed Analysis -> Object Name "<IC_NAME>"), so E, F and DIM tables.
    2.You can use RSRV -> All Elementary Tests -> Database -> Database information about infoprovider tables to get the rows in the fact tables and dimension tables.
    You can also use the program SAP_INFOCUBE_DESIGNS.
    3.GoTo T.Code, DB02 and there u can see the over all DataBase details. Look down in the "Tables, Indexes, stored procedures" there select Space Statistics then it will popup a selection there select Top n largest tables and check the PSA Table with the Table Name like /BIC/B0000264000.
    If u have several requests in the PSA then u can delete them having a few requests in the PSA.
    4.In DB02 Transaction Code see at the bottom u could see these,
    1. Detailed Analysis
    2. Missing Indexes
    3. Space statistics
    4. Checks
    In this select the 3rd one, u should get the popup.
    Check this link:
    Re: RSRV not showing number of records
    Hope this helps,
    Regards,
    Ravikanth

Maybe you are looking for