Rollback CMP Transaction

Hi
I am checking for one object and if that is null i want to throw Application exception from my EJB. Now if i thorw application exception container does not rollback the data. We need to set ctx.setRollbackOnly.
say i have method
public void setData(ValueObject MyVO)
if(MyVO!=null)
// do something
else
ctx.setRollbackOnly()
throw new myexception("Null obj VO");
am i on the right track. I beleive this will allow me to throw application exception as well as rollback the transcation.
I am using weblogic 7.0 with ejb2.0 and CMR relations. All my transactions attributes are set to Required
Pranav

Hey thanks for your input.
But just a quick question for you.
Can i create a application exception extends EJBException
so that now when i thorw MyExp it will not have to call ctx.setRollbackOnly.
Like this
TestEJB.java
public void setData(MyVO vo)
if(vo==null)
thorw new MyExp("Cannot be null");
in this even if i dont call rollback on context still it will rollback cos now my exception is child of ejbexception(system exception)
am i right
which is the best way to do though.
This one or one which i asked as first quesrtion
thanks
pranav

Similar Messages

  • Rollback a transaction in a session bean BMP?

    The following code would work correctly if executed in a stateless session bean BMP?
    InitialContext ic = new InitialContext();
    javax.sql.DataSource dataSource = (javax.sql.DataSource) ic.lookup("java:comp/env/jdbc/OracleDS");
    Connection conn = dataSource.getConnection();     
    conn.setAutoCommit(false);
    Statement stmt = conn.createStatement("UPDATE TABLE_A SET NAME = 'Duke' WHERE ID = 7");
    stmt.executeUpdate();
    if (someCondition) {
    conn.commit();
    } else {
    conn.rollback();
    My question:
    It�s possible to rollback a transaction using rollback() from Connection class in a stateless
    session bean BMP?

    Dear JDC member:
    With EJB, you can gain the benefit of transactions without performing any transaction programming. That is, your enterprise beans never explicitly issue a begin, commit, or abort statement. The container performs it to you. But you have to tell the container how to do it. As you might know, the deploment descriptor is the place for it.
    But nothing prevent you to do do programmatic transaction as you want.. For that case you have to know JTA (Java Transaction API) and more.
    Suppose the transaction aborts, you have to throw an exception back to the client or try it again. The issue here is with stateless sesssion beans, there is no in-memory conversational state. You might think to implement javax.ejb.SessionSynchronization interface with your business methods....
    You see there is a lot to know. You can take care of transactions in the client code, but it is a bad design.
    You have to understand today most application servers (Websphere, Weblogic...) are designed to minimize those issues in order to make developers' tasks easier. The container takes care of transactions.
    Be careful when you write stateless session beans BMP (BMP are for entiti beans)
    Regards,
    Armand Komenan

  • How can I rollback a transaction using EJBContext.rollbackOnly()?

    I failed to rollback a "required" method of a seesion bean using EJBContext.rollbackOnly() , but it rollbacked if I throw EJBException , how can I rollback a transaction by
    EJBContext.rollbackOnly() ? Thanks for your help.
    regards,
    dean

    The full and partial updates (whether it be Thunderbird, Firefox or SeaMonkey) from mozilla.org are only provided to the official builds and not builds built yourself or by a third-party.
    The openSUSE and other Linux distro provided builds have their own ways of package updates in their package manager.
    However if the poster is using Thunderbird for Linux from http://www.mozilla.org/en-US/thunderbird/ (64-bit Linux is on ftp) then those preferences would be valid and work.
    Nothing is being gutted as it has been this way since forever with third-party builds whether on Windows, Mac OSX and Linux.

  • Just another cmp transaction question

    Hi
    I would like to know if it is possible to manage cmp transaction from the client code. For example I need to
    execute some business method several times but I don't want the container to commit transaction after each execute but only if all executes were successfull.
    Bartek

    I think I understand your post but my problem is rather different. I have a session bean with a business method named process(..) that receives as an argument a org.dom4j.Document object and does an proper action. I works fine when that process() method is called only one . But now I wan't to call it several times , each time with different org.dom4j.Document perhaps and want to have tha transaction commited only after complete whole process. I am quite new I ejbs so it is possible that is quite a silly question but I need surety that the only way to do this is to make an another session bean business method that gets as a parameter for example a collection of org.dom4j.Document objects.
    Thanks for help
    Bartek

  • Rollback per transaction issue

    hi
    i found in our live database Rollback per transaction: 92.86% how i can troubleshoot this value and what is the rezone and how i can solve it

    Hi,
    this is more likely to be an application issue, not a database one. I heard of webservers that do a rollback after each query (!), maybe it's one of them, or a similar error in the application design. I have also once come across a case when there was a great number of fake commits on the system (so called "readonly commits") which were caused by an internal Oracle bug. The problem was resolved by applying a patch -- so you may want to check MOS articles for similar symptoms.
    Best regards,
    Nikolay

  • Get IllegalStateException when rollback client transaction while thansaction is already rollbacked by Container

    Hi,
              I use WL5.1.0 + SP8. When I start a client-demarcated transaction and
              call two methods in EJB, the second method will throw a system level
              exception (such as RemoteException), the container rollback the
              transaction so that when I catch the exception in client and try to
              rollback by myself, I got an IllegalStateException: There is no
              transaction associated with this thread.
              In SP8, I thought they fixed this problem and the container is supposed
              to mark the transaction rollbacked and throw
              TransactionRolledbackException to client instead of rollback this
              transaction.. But obviously it still doesn't work in SP8.
              Is this still a bug or am I missing something?
              Thanks a lot!
              Tao
              

    Hi,
              I use WL5.1.0 + SP8. When I start a client-demarcated transaction and
              call two methods in EJB, the second method will throw a system level
              exception (such as RemoteException), the container rollback the
              transaction so that when I catch the exception in client and try to
              rollback by myself, I got an IllegalStateException: There is no
              transaction associated with this thread.
              In SP8, I thought they fixed this problem and the container is supposed
              to mark the transaction rollbacked and throw
              TransactionRolledbackException to client instead of rollback this
              transaction.. But obviously it still doesn't work in SP8.
              Is this still a bug or am I missing something?
              Thanks a lot!
              Tao
              

  • Statspack Rollback per transaction % vs Log Miner rollback = 1

    Hi,
    I'm investigating high Rollback per transaction % = 30% in our 9.2.0.8 EE databse .
    First think was checking all archive logs from period equal to statspack snapshot range
    but looks like there is huge discrepancy between that two tools .
    What I've found from v$logmnr_contents where rollback = 1 was that
    only 0,5% transactions was rollbacked .
    I'm wondering what could cause such difference is that true
    unique constraint violation (or other exceptions) is not recorded in redologs as rollbacked transaction ?
    Any ideas ?
    Major problem is still what is causing high rollback % .
    Regards
    G

    I'm investigating increase in undo usage and Rollback per transaction % = 30 .
    Strange issue because v$transacion is not showing demanding transacions , rather small quick (oltp system).
    Here is sp report:
    DB Name     DB Id  Instance   Inst Num Release   Cluster Host
    XXXX     1497360911 XXXXX        1 9.2.0.8.0  NO   XXXXX
           Snap Id   Snap Time   Sessions Curs/Sess Comment
    Begin Snap:   89346 23-Sep-09 08:00:02   638   13.0
    End Snap:   89365 23-Sep-09 20:00:05   710   19.1
      Elapsed:       720.05 (mins)
    Cache Sizes (end)
    ~~~~~~~~~~~~~~~~~
            Buffer Cache:   3,072M   Std Block Size:     8K
          Shared Pool Size:   2,048M     Log Buffer:   2,000K
    Load Profile
    ~~~~~~~~~~~~              Per Second    Per Transaction
             Redo size:      344,858.21       6,796.87
           Logical reads:      131,932.52       2,600.28
           Block changes:       2,211.70         43.59
           Physical reads:       7,457.34        146.98
          Physical writes:        236.52         4.66
             User calls:       6,197.31        122.14
               Parses:       2,236.26         44.07
            Hard parses:         20.63         0.41
               Sorts:        330.72         6.52
               Logons:         0.34         0.01
              Executes:       3,097.97         61.06
            Transactions:         50.74
    % Blocks changed per Read:  1.68  Recursive Call %:   35.95
    Rollback per transaction %:  30.58    Rows per Sort:   31.38
    Instance Efficiency Percentages (Target 100%)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          Buffer Nowait %:  99.97    Redo NoWait %:  100.00
          Buffer Hit  %:  94.37  In-memory Sort %:  100.00
          Library Hit  %:  99.63    Soft Parse %:   99.08
         Execute to Parse %:  27.82     Latch Hit %:   99.83
    Parse CPU to Parse Elapsd %:  30.18   % Non-Parse CPU:   95.65
    Shared Pool Statistics    Begin  End
           Memory Usage %: 100.00 100.00
      % SQL with executions>1:  38.24  35.74
    % Memory for SQL w/exec>1:  76.94  86.29
    Top 5 Timed Events
    ~~~~~~~~~~~~~~~~~~                           % Total
    Event                        Waits  Time (s) Ela Time
    CPU time                           109,020  32.54
    db file sequential read            40,144,341   96,883  28.91
    db file scattered read             26,524,497   66,948  19.98
    sbtwrite2                    4,141,351   23,994   7.16
    SQL*Net message from dblink          33,497,630   17,097   5.10
         -------------------------------------------------------------

  • Rollback on transaction failes

    Hi,
    I have got a problem when I try to rollback a transaction using a JDBC driver, but I don't understand why. Maybe someone can help me.
    My problem is as follows:
    on a connection with AutoCommit set to true, I define some INSERT actions on a certain table. Hereafter I do a commitTransaction(). This generates a SQLException, which I catch. In this catch I do a connection.rollback(). This results in the following error:
    [SQLServer JDBC Driver]Not in local manual transaction mode
    Does anyone know what this means and what causes this?
    Regards,
    Onno Kievit

    Hi Onno,
    If you have enabled "auto commit", then you cannot call methods like "commit()" or "rollback()". After you have executed your INSERT, a "commit" automatically happens -- if the INSERT succeeds -- or a "rollback" automatically happens (if the INSERT fails). You are calling the "commit()" method when there is no open transaction -- which is wrong and therefore you get an error (SQLException).
    Same problem occurs when you catch the error caused by your "commit" and try to "rollback" -- you cannot "rollback" when there is no open transaction.
    As I see it, you have two choices:
    1. disable auto commit, or
    2. remove the calls to "commit()" and "rollback()"
    Hope this helps you.
    Good Luck,
    Avi.

  • User interference with CMP transaction (illegal termination of transaction)

    Folks,
    Have any one encountered this error before ? Let me know the root cause of this error if you do know about it.
    thx.
    Rajesh.

    Hello.
    The error occurs when the method SmsOmniServiceBean.proceedOMNI() calls REMOTELY the method SmsOmniServiceBean.proceedOMNIinternal(). What is important is that the call is a remote call (using JNDI, the home and remote interface) that creates a new transaction (the method proceedOMNIinternal() transaction is defined as "requiresNew" in the ejb-jar.xml). This is done on purpose. If the proceedOMNIinternal() transaction is rolled back, we do not want that the whole transaction is rolled back.
    Please note that the calling method proceedOMNI() is execute in a loop inside another method (proceedOMNIAll()), and the exception is thrown at some random point in the loop: sometimes near the middle, sometimes near the end.
    Please note also that no entity bean are used in our application, nor in another application deployed on the server, so why "User interference with CMP" ?
    Here is the stack trace:
    com.evermind.server.rmi.OrionRemoteException: User interference with CMP transaction (illegal termination of transaction)
         at SmsOmniService_StatelessSessionBeanWrapper92.proceedOMNIinternal(SmsOmniService_StatelessSessionBeanWrapper92.java:736)
         at com.bnpparibas.bfi.sms.server.ejb.SmsOmniServiceBean.proceedOMNI(SmsOmniServiceBean.java:223)
         at com.bnpparibas.bfi.sms.server.ejb.SmsOmniServiceBean.proceedOMNIAll(SmsOmniServiceBean.java:299)
         at SmsOmniService_StatelessSessionBeanWrapper92.proceedOMNIAll(SmsOmniService_StatelessSessionBeanWrapper92.java:479)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:479)
    Thank you in advance for your answer,
    Pierre Laroche

  • Difference between Transaction.rollback() and Transaction.setRollBackOnly()

    Hi,
    I wanted to know the difference between what typical implementations of Transaction.rollback() and Transaction.setRollbackOnly().
    I have used setRollbackOnly()? in distributed transaction scenarios. How is it different from rollback()?
    Thanks
    Shailesh

    I would really recommend posting this question in a forum where somebody might understand what you are talking about. This is the XML forum.

  • Rollback per transaction too high

    Hi, I am investigating performance problems on our database which is used by a third party application.
    Using the stats' pack I have established that the
    Rollback per transaction % is very high (between 60-70%).
    I am on version 8.17 or Oracle, the application is written in powerbuilder. And it users lots of sessions per user.
    A typical user users 5-7 sessions .
    How can i find what is causing all this rollback?
    could it be related to all these sessions ?

    Hi,
    The Rollback Per Transaction statistic will report on all statements that were rolled back, regardless of whether there is anything to rollback or not.
    You can see more information about statspack report into metlink note 228913.1 - Systemwide Tuning using STATSPACK Reports
    Nicolas.

  • Java.sql.SQLException: Cannot rollback a transactional connection

    Hi
    This is what i am trying to do:
    try{
    conn = getConnection();
    conn.setAutoCommit(false);
    execQuery(sql_1);
    execQuery(sql_2);
    conn.commit();
    }catch(Exception ex){
    conn.rollback();
    i have made an error in sql_2 so i get an Exception. My queries use the same "conn" so the rollback should applay to the first query but it has made a commit. How do i get rollback to work?
    I read this in an other topic:
    Make sure that you configure your database connection in the jboss.jcml and not in the bean (or servlet) itself.
    Then, make a lookup via jndi. On this way, the driver gets bound to the transactionManager and the rollback() works finde.
    But i don�t know how to configure the connections, and how does the trasactionManager work.
    Can some one help me?

    Maybe i should ad that i am using Oracle db an the
    code is in a Entity BeanThis changes the way you want to do rollbacks. Rollbacks in ejbs are handled by the container. In order to do rollbacks, you need to flag the transaction as to be rolled back. To do this, you need to call the method setRollbackOnly() in the ejb's SessionContext - sessionContext.setRollbackOnly();
    For this to work correctly, you must declare the method in the ejb's deployment descriptor as requiring to handle transactions by specifying the appropriate value for the <tran-attribute> element of you ejb's dd.
    BTW, you'd be better off posting EJB related question in the J2EE SDK forum.

  • How to rollback previous transaction in a series of Adapters in BPEL

    in Bpel process we integrate 3 db adapters,
    2 adapters are successfully complted,3rd adpter failed.
    inthis situation how we rollback the 3 adapter transaction with out using of compensate handling

    hey,i have made the code plz chk it and do rep soon as ma project sbmission date is very near =((
    i am snaping an image from the web cam then comparing it with the red colored jpg image made in paint.
    the jpg image is converted  to give input image to imaq match vi.but after the comparison it gives the same output.
    on the front pannel the snapped image is displayed,the red colored image that is converted in to its respective pixels is displayed and the image that is obtained after cheking the image in the draw fails vi...the pic converted to pixels is all the time displayed.and the pass/fail icon always denotes one pass led on..plz chk the code =((.
    also can u provide me some guide line for using thr hough transform for the red color detection in lab view..i dont have to import the matlab code..i have to purely make it using the lb view libraries.
    also one more request pl rep me regularly as i really need your golden piece of advice for ma success.
    thnx
    Attachments:
    picture to image(BY ME).vi ‏102 KB
    untitled.JPG ‏3 KB

  • Needed to ROLLBACK failed Transaction

    Hi Oracle Expertz,
    QRY will Look Like
    BEGIN
    INSERT into tab3 RETURNING INTO v_exer_num
    UPDATE tab1
    SET col1 = ''
    WHERE exer_num = v_exer_num
    UPDATE tab2
    SET col1 = ''
    WHERE exer_num = v_exer_num
    END ;
    Example :
    1st record:
    Participant A
    Exer 1 Success
    Exer 2 Success
    2nd record
    Participant B
    Exer 1 Failed due to dead lock or some other exception.
    3rd Record
    Participant C
    Exer 1 Success
    Now in this transaction, I need to only rollback for Participant B ( failed Record) . Participants A and C should have committed the transaction. Can any one suggest me on this?
    Possiblities Of Exception :
    successful of INSERT , UPDATE , UPDATE will be considered as a completed tranasaction.
    For a particular record ( exer_num) , If insertion is executed successfully ,and updates failed for the corresponding exernum , I need to rollback the inserted record .
    Regards,
    Maran
    Edited by: Maran on Aug 6, 2009 1:17 PM

    Hey Sven ,
    thanks for your response. No these three DML statements would be executed inside my procedure. We can not run it in different session. the reason is
    as i said, completion of these 3 DML statements , then only will conisdered as a successful transaction else i need to roll back .
    also this will be called in a Batch JOB. we have a commit for whole transaction.
    Lets these are all the possibilites :
    1) INSERT FAILED ( ROW 1 )
    2) INSERT SUCCESS (ROW 2 )
    1st UPDATE Failed
    3) INSERT SUCCESS ( ROW 3 )
    1st UPDATE SUCCESS
    2nd UPDATE D FAILED
    4) INSERT SUCCESS ( ROW 4)
    UPDATE SUCCESS
    UPDATE SUCCESS
    Now for these scenario none of three statements got executed successfully . So if it fail between any of the statements , I need to rollback that particular row.
    Hope you understand the problem well now.
    Now can anyone suggest me that How can i handle this exception and need to keep going my transaction even if it fails in between.
    Objective over this problem is :
    Need to rollback Failed rows.
    Need to keep continue the Program , need to commit successful rows.
    Regards,
    MARAN
    Edited by: Maran on Aug 10, 2009 6:19 PM

  • Finders/CMP transactions

    Hello,
    I've got some weird behaviour happening on my finders.
    I've got a CMP bean and a Session bean on top of it.
    The session bean has a method that performs the following:
    1 - creates an instance of the CMP bean
    2 - updates an attribute on this instance of the CMP
    3 - perform another find on the CMP.
    Now the first 2 steps are ok. The 3rd step is a problem.
    If I do a find by PK then it works.
    But if I perform a custom finder that specifies one of the attributes that was updated in step 2, (eg, age=1, where age is an attribute on the CMP etc), then it doesn't return the CMP.
    If I retrieve the bean at this point in time through a find by PK and check the updated attribute, it returns the updated value.
    So it is as if the custom finder is some how executed in a different transaction from the rest of the method, as it doesn't see the fact that I've updated the attribute in step 2.
    Note that if I call the custom finder in step 1, after creation, it works properly.
    I've got the transaction attribute on the session bean to Requires and all the entity bean methods are set to Requires.
    BTW, I'm using OC4J 1.0.2.2.1.
    Any ideas,
    Thanks!!!,
    Ricky

    you can find DuplicateKeyException is this place
    http://java.sun.com/j2ee/1.4/docs/api/
    javax.ejb.DuplicateKeyException.
    DuplicateKeyException - exception javax.ejb.DuplicateKeyException.
    The DuplicateKeyException exception is thrown if an entity EJB object cannot be created because an object with the same key already exists.
    But I cannot find how to use DuplicateKeyException in SAP applications
    Very Sorry.

Maybe you are looking for

  • External Disk Not Readable by OSX after Setting Drive Letter in Windows 7

    My external hard drive, which was previously formatted as Mac OS Extended (Journaled), contains all of my purchased music. I have this external drive connected directly to my iMac via USB. My iTunes in OS X points to this drive. After installing Boot

  • Please provide me the oracle material

    Hi , i am new to oracle i am eager to learn oracle(all commands for dba and developer) . could any body have the small material(not big) with all the commands used in the oracle (presently i want to strong in basics of oracle commands) .can any body

  • How to do averaging N samples for several channels?

    Dear members, I got the Routine for averaging N Samples from One channel's data from the forum. I would like to do for several channels. How to go about it? Regards, G.Kousalya

  • Transfer of profit center balances from old profit center to new profit cen

    HI, My client wants to deactivate all cost centers and profit centers and create new cost centers and new profit centers for new fiscal year 2009. So here my queries are 1. Putting an end date to the existing cost center and creating the New cost cen

  • Downloading the LiveCycle ES2 Turnkey Within a firewall....

    I am working with a customer that is trying to download the LiveCycle ES2 JBoss Turnkey from within their firewall.  This organization has very strict pc requirements and does not allow Java applets to run so they are running into issues using the Ad