MDB Container Managed Transaction and Log4J

Hi,
I'm programming and MDB that reads and updates a database then sends out an HTTP Post and logs using log4j. I've read that when an MDB is configured as CMT or container managed transaction and the OnMessage method executes without errors, the transaction is implicitly commited. You can rollback the transaction by explicitly calling setRollbackOnly() or when a RuntimeException has been thrown. My worry is that after I have sent out an HTTP POST (a transaction has been completed) I would have to log a transaction completion using log4j. My problems is if log4j throws a RuntimeException thereby rolling back my transaction which shouldn't be the case. What I have done is to catch all Exceptions (and swallow them) whenever I log using log4j after I have sent out an HTTP POST succesfully (since my transaction should be complete by then). Is this a correct workaround?
Thanks :)

Your approach is correct. If you think, Log4J might throw errors, swallow the exceptions and try not to roll back.

Similar Messages

  • About Container-managed Transactions and Bean-managed Transactions

    as the document of weblogic7.0 describe the differents of Container-managed
              Transactions and Bean-managed Transactions,and in the document,It tell us
              details of using Bean-managed Transactions,such as \:
              import javax.naming.*;import javax.transaction.UserTransaction;.....
              import java.sql.*;import java.util.*;
              UserTransaction tx = (UserTransaction)
              ctx.lookup("javax.transaction.UserTransaction");tx.begin();
              tx.commit() //or tx.rollback
              but how to use Container-managed Transactions?
              what is EJB's deployment descriptor? can someone tell me?
              i wonder someone will show me an example of how to use Container-managed
              Transactions.
              thanks
              fish
              

    Many if not all of the WLS EJB examples use container-managed
              transactions. That's a good place to start.
              I'd also recommend that you pick up a decent EJB book. There's several
              on the market right now.
              -- Rob
              fish wrote:
              > <ejb-jar>
              > <enterprise-beans>
              > <session>
              > <ejb-name>testbean</ejb-name>
              > <home>test.test.TestHome</home>
              > <remote>test.test.Test</remote>
              > <ejb-class>test.test.TestBean</ejb-class>
              > <session-type>Stateful</session-type>
              > <transaction-type>Container</transaction-type>
              > </session>
              > </enterprise-beans>
              >
              > <assembly-descriptor>
              > <container-transaction>
              > <method>
              > <ejb-name>EmployeeRecord</ejb-name>
              > <method-name>*</method-name>
              > </method>
              > <trans-attribute>Required</trans-attribute>
              > </container-transaction>
              > </assembly-descriptor>
              > </ejb-jar>
              > ----------------------------------------------
              > seems i have to write ejb-jar.xml like this,am i right?
              > what about <ejb-client-jar>? is it needed in this xml file?
              >
              > thanks
              >
              > fish
              >
              >
              

  • MDB container managed transaction demarcation not working in wls 6.1 beta

    I have an MDB which sends the messages it receives onto another JMS
              destination within the onMessage method. These messages are not sent to
              the JMS destination unless I explicitly use a transacted session for the
              destination and subsequently commit the session. If I set the transacted
              parameter to Session as false the messages are sent. If I set the
              transacted parameter to true the messages will only be output if the
              session is committed. This is the standard behaviour for a JMS session
              but this is not the correct behaviour for an MDB running with
              container-managed transaction demarcation.
              For a start the transacted parameter to session should be ignored when
              run in the context of a container transaction and the commit method
              should thrown an exception as it is not allowed within the context of a
              container transaction.
              This is the MDB code and the deployment descriptor: -
              public class MessageBean implements MessageDrivenBean, MessageListener
              private String topicName = null;
              private TopicConnectionFactory topicConnectionFactory = null;
              private TopicConnection topicConnection = null;
              private TopicSession topicSession = null;
              private Topic topic = null;
              private TopicPublisher topicPublisher = null;
              private TextMessage textMessage=null;
              private transient MessageDrivenContext messageDrivenContext = null;
              private Context jndiContext;
              public final static String
              JMS_FACTORY="weblogic.examples.jms.TopicConnectionFactory";
              public final static String
              TOPIC="weblogic.examples.jms.exampleTopic";
              public MessageBean()
              public void setMessageDrivenContext(MessageDrivenContext
              messageDrivenContext)
              this.messageDrivenContext = messageDrivenContext;
              public void ejbCreate()
              public void onMessage(Message inMessage)
              try
              jndiContext = new InitialContext();
              topicConnectionFactory =
              (TopicConnectionFactory)jndiContext.lookup(JMS_FACTORY);
              topic = (Topic) jndiContext.lookup(TOPIC);
              topicConnection =
              topicConnectionFactory.createTopicConnection();
              topicConnection.start();
              // The transacted parameter should be ignored in the context of a
              container tx
              topicSession = topicConnection.createTopicSession(true,
              Session.AUTO_ACKNOWLEDGE);
              topicPublisher = topicSession.createPublisher(topic);
              textMessage = (TextMessage)inMessage;
              topicPublisher.publish(inMessage);
              // this is illegal in a container transaction
              topicSession.commit();
              topicConnection.close();
              catch (JMSException je)
              throw new EJBException(je);
              catch (NamingException ne)
              throw new EJBException(ne);
              public void ejbRemove()
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
              JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
              <ejb-jar>
              <enterprise-beans>
              <message-driven>
              <display-name>MessageBean</display-name>
              <ejb-name>MessageBean</ejb-name>
              <ejb-class>MessageBean</ejb-class>
              <transaction-type>Container</transaction-type>
              <message-driven-destination>
              <destination-type>javax.jms.Queue</destination-type>
              </message-driven-destination>
              <security-identity>
              <description></description>
              <run-as>
              <description></description>
              <role-name></role-name>
              </run-as>
              </security-identity>
              </message-driven>
              </enterprise-beans>
              <assembly-descriptor>
              <container-transaction>
              <method>
              <ejb-name>MessageBean</ejb-name>
              <method-name>*</method-name>
              </method>
              <trans-attribute>Required</trans-attribute>
              </container-transaction>
              </assembly-descriptor>
              </ejb-jar>
              

    Please see the response in the EJB newsgroup.
              Also, could you kindly only post to a single newsgroup?
              Thanks.
              "Jimmy Johns" <[email protected]> wrote in message
              news:[email protected]...
              > I have an MDB which sends the messages it receives onto another JMS
              > destination within the onMessage method. These messages are not sent to
              > the JMS destination unless I explicitly use a transacted session for the
              >
              > destination and subsequently commit the session. If I set the transacted
              >
              > parameter to Session as false the messages are sent. If I set the
              > transacted parameter to true the messages will only be output if the
              > session is committed. This is the standard behaviour for a JMS session
              > but this is not the correct behaviour for an MDB running with
              > container-managed transaction demarcation.
              >
              > For a start the transacted parameter to session should be ignored when
              > run in the context of a container transaction and the commit method
              > should thrown an exception as it is not allowed within the context of a
              > container transaction.
              >
              > This is the MDB code and the deployment descriptor: -
              >
              > public class MessageBean implements MessageDrivenBean, MessageListener
              > {
              > private String topicName = null;
              > private TopicConnectionFactory topicConnectionFactory = null;
              > private TopicConnection topicConnection = null;
              > private TopicSession topicSession = null;
              > private Topic topic = null;
              > private TopicPublisher topicPublisher = null;
              > private TextMessage textMessage=null;
              > private transient MessageDrivenContext messageDrivenContext = null;
              >
              > private Context jndiContext;
              >
              > public final static String
              > JMS_FACTORY="weblogic.examples.jms.TopicConnectionFactory";
              > public final static String
              > TOPIC="weblogic.examples.jms.exampleTopic";
              >
              > public MessageBean()
              > {
              > }
              >
              > public void setMessageDrivenContext(MessageDrivenContext
              > messageDrivenContext)
              > {
              > this.messageDrivenContext = messageDrivenContext;
              > }
              >
              > public void ejbCreate()
              > {
              > }
              >
              > public void onMessage(Message inMessage)
              > {
              > try
              > {
              > jndiContext = new InitialContext();
              > topicConnectionFactory =
              > (TopicConnectionFactory)jndiContext.lookup(JMS_FACTORY);
              > topic = (Topic) jndiContext.lookup(TOPIC);
              > topicConnection =
              > topicConnectionFactory.createTopicConnection();
              > topicConnection.start();
              > // The transacted parameter should be ignored in the context of a
              > container tx
              > topicSession = topicConnection.createTopicSession(true,
              > Session.AUTO_ACKNOWLEDGE);
              > topicPublisher = topicSession.createPublisher(topic);
              > textMessage = (TextMessage)inMessage;
              > topicPublisher.publish(inMessage);
              > // this is illegal in a container transaction
              > topicSession.commit();
              > topicConnection.close();
              > }
              > catch (JMSException je)
              > {
              > throw new EJBException(je);
              > }
              > catch (NamingException ne)
              > {
              > throw new EJBException(ne);
              > }
              > }
              >
              > public void ejbRemove()
              > {
              > }
              > }
              >
              >
              >
              >
              > <?xml version="1.0" encoding="UTF-8"?>
              >
              > <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
              > JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
              >
              > <ejb-jar>
              > <enterprise-beans>
              > <message-driven>
              > <display-name>MessageBean</display-name>
              > <ejb-name>MessageBean</ejb-name>
              > <ejb-class>MessageBean</ejb-class>
              > <transaction-type>Container</transaction-type>
              > <message-driven-destination>
              > <destination-type>javax.jms.Queue</destination-type>
              > </message-driven-destination>
              > <security-identity>
              > <description></description>
              > <run-as>
              > <description></description>
              > <role-name></role-name>
              > </run-as>
              > </security-identity>
              > </message-driven>
              > </enterprise-beans>
              > <assembly-descriptor>
              > <container-transaction>
              > <method>
              > <ejb-name>MessageBean</ejb-name>
              > <method-name>*</method-name>
              > </method>
              > <trans-attribute>Required</trans-attribute>
              > </container-transaction>
              > </assembly-descriptor>
              > </ejb-jar>
              >
              >
              >
              >
              >
              >
              >
              >
              

  • Container Managed Transactions

    Hi everyone
    I've been reading some documentation about Container Managed Transactions and I am not sure if I understood the actual meaning of the "required" attribute.
    Imagine one user calls a method (whith "required") wich joins a transaction. If another user calls the same method at the same the transaction is running, that means this method joins the same transaction of the other user? Or this only happen if the first user calls another "required" method?
    Thanks

    If another user calls the
    same method at the same the transaction is running,
    that means this method joins the same transaction of
    the other user? Or this only happen if the first user
    calls another "required" method?
    Not sure what you mean. First a txn of one user is isolated from the txn of another (remember the ACID props of txns). So a given txn spawn by one user can never be 'joined' by another.
    What 'required' means is that, for one given user, if a txn is in progress already from a method (method 1) when another method (method2) is called, method2 joins the txn in method1; if there were no txn in method1, a new txn is started in method2.

  • Bean Managed Transactions and rollback

    Hi Everybody,
    I am using Bean Managed Transactions in a Message Bean which is called every some time by an EJB3 timer. This Message Bean subsequently calls a Session Bean which uses Container Managed Transactions and uses the default transaction attribute which is SUPPORTS. The Session Bean methods might sometime throw a System Exception(inheriting from RuntimeException) which will rollback the Bean Managed Transaction which was started from the Message Bean.
    When this happens and I try to invoke userTransaction.rollback() I get invalid transaction state exception and I suppose this means that is already rolled back.
    Is there a way to get another transaction or set the transaction back to a valid state so I can carry on with some persistence tasks or the only way to do that is by suppressing the RuntimeException and throwing an Application Exception having the *@ApplicationException(rollback=false)* annotation? Can I suppress a System Exception though?
    Thank you in advance!

    Saroj wrote:
    Hi All,
    I would like to know whether we can use JDBC Connection Object's commit and rollback
    methods to control Transaction in Bean Managed Transactions or not.You may use the JDBC connection's transaction support from an EJB. That being said, you
    need to understand that it won't be the transaction that started declaratively by the
    EJB container nor would it be a bean-managed transaction started through
    UserTransaction.
    FWIW, I question why you'd want to do this though. I'd use container-managed
    transactions and let the container handle this for you. The transaction manager
    includes a 1PC optimization so it's not going to do an XA/2PC tx if you only have a
    single resource in the tx. Also, the EJB container includes all the logic to properly
    handle rollbacks when exceptions are thrown etc.
    Finally, your code will more maintainable and reusable if you use the container-managed
    tx + JTA resources. If I later wanted to call another EJB or another JTA resource (eg
    JMS perhaps) I could do it without having to rewrite all of your code.
    -- Rob
    >
    >
    Why is it required that we should use Java Transaction API to control the Transaction
    in Our Beans?
    I understand that if we are using Multiple Resources and need to use Transaction
    then going for JTA makes sense. If I am using only Resource,for example, Only One
    Connection then we should be able to use Connection's Transaction control.
    I understand that other way to do the transaction is to use Container's transaction
    services.
    Please respond at the earliest.
    Thanks in Advance,
    Saroj

  • Container managed transactions in 9.0.3 (plus AQ JMS/MDB)

    Something for "real programmers", similar to MDB Transaction Exception on OC4J 9.0.4 (MDB Transaction Exception on OC4J 9.0.4) but little bit different. Maybe author of the mentioned thread can find some answers here also.
    We have an MDB accessing AQ in database (this works either with 9i and 8i). MDB receives the message (actually TextMessage), retrieves the content/properties and calls some EJBs making database operations. When we used just the same DataSource for JMS resource provider and SQL operations, everything worked OK. But we need to move one step further - making calls to several databases, some 8i, some might 9i. We were able to start CMT for one DataSource, i. e. configuring OrionCMTDataSource over JDBC ORACLE driver (if you use different DataSource class, message remains stucked in queue and eventually expires. If you don't specify container managed transactions for MDB in ejb-jar.xml, it works with any DataSource class - but message is lost every time exception occurs - not very pleasant situation).
    We are trying to configure DataSources so they provide transactional support while using commit coordinator. There are some documents describing this - in 9iAS Data Sources and JTA, Orion Data Sources and possibly JTA description in 9i database documentation. Both ORACLE documents are very similar. Generally, these are main steps:
    1) configure each data source so they provides CMT support (wrap native driver/data source by OrionCMTDataSource class)
    2) create datasource commit-coordinator database, also using CMT(?)
    3) create user in commit-coordinator database and same in each other database with connect, resource, create session + force any transaction priviledge (since it would commit other users transactions)
    4) create database links from commit-coordinator database to each databases (but... see questions below)
    5) configure commit coordinator so it uses proper data source
    6) add each DB link as a property to data sources
    7) configure data source for JMS
    8) connect JMS resource provider with JMS data source
    9) Start container, send message, etc.
    So far the only result we've got is a trace file in database user dumps and generic "javax.transaction.SystemExeption: Could not commit: error code 29540". User dump occurs in a "remote" database, not the one where commit coordinator resides. If I drop database links, result is the same, so it seems like problem with data source itself. In a dump there is piece of text like this: "FATAL ERROR IN TWO-TASK SERVER: error = 12571" and "ksedmp: internal or fatal error
    Current SQL statement for this session:
    begin dbms_aqin.aq$_dequeue_in( :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29); end; ". I think AQ call is just a coincidence since it is the first one involved in transactions. Down there in HEX part of a dump there is a message about protocol or network error ("probably ORA-28546")
    Here is an example of data source configuration we are using:
    <!-- Passport CMT DataSource -->
    <data-source
    name="PassportDS"
    class="com.evermind.sql.OrionCMTDataSource"
    location="jdbc/PassportDS"
    connection-driver="oracle.jdbc.driver.OracleDriver"
    username="int"
    password="int"
    url="jdbc:oracle:thin:@ws18885:1521:ICON"
    inactivity-timeout="30">
    <property name="dblink" value="ICON.WS18885.APPG.COM"/>
    There are some questions pending. Obvious one is if CMT is working or not at all and we should find some different solution (Bean managed transactions or use XA, hmmm). Other one might be that database link has to be "fully-qualified". I'm not sure what it means: using username and password? Using database name along with domain (if any)? So far it seems links are not used anyway.
    We've tried several databases, like 9.2.0.1 and 9.0.3 versions. Result is the same.
    We've tried to use XA data source of ORACLE (oracle.jdbc.xa.client.OracleXADataSource) and OrionCMT data source bound by xa-source-location to it but container gets stucked upon restart with "Investingating resource 'XADataSource PassportXADS' for recovery..." and similar messages for an hour.
    There is an OracleJTADataSource mentioned in several documents, but I cannot find any in jdbc classes - was it deprecated?
    Lies the problem in JMS itself? So far we've been able to use AQ in 8i and 9i and succesfully commit every transaction - provided transaction was local.
    Since XA itself is working I guess problem might be with configuration.
    I will appreciate any opinion on CMT... also, if you have any questions, please ask.
    Myrra

    Hi Per,
    I don't have an answer for you -- sorry {:-( -- only a suggestion (which
    you may have already tried, anyway :-). Have you tried running OC4J
    in "debug" mode? The following web-page gives details on how to do that:
    http://kb.atlassian.com/content/atlassian/howto/orionproperties.jsp
    Also, if you aren't already aware of them, the following web-sites
    may also be helpful (not in any particular order):
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.elephantwalker.com
    Good Luck,
    Avi.

  • Sending message to a JMS queue and making DB update through a single container managed transaction

    Can we use container managed transactions to send message to JMS queue and make DB updates in a sigle transaction. If yes then do we need 2pC license. I am using weblogic 6.0 SP2 and my database driver do not supports XA

    If your JMS provider is XA compliant, you can.
    If you are using WebLogic 6.0 JMS, it supports 2PC.
    The JDBC resource that does not support XA can participate in the global transaction
    creating a TXDataSource and setting "enable two-phase commit"=true in the Configuration
    panel.
    About the JMSConnectionFactory, on the console, in WebLogic 6.0, in the "Transaction"
    tab folder, set "User Transactions Enabled"=true.
    In your code, use non-transacted sessions.
    For 2pc protocol, you need a license or you'll get an exception.
    Sergi
    Manoj Bansal <[email protected]> wrote:
    Can we use container managed transactions to send message to JMS queue and
    make DB updates in a sigle transaction. If yes then do we need 2pC license.
    I am using weblogic 6.0 SP2 and my database driver do not supports XA

  • JMS Sender with ejb3 container managed transaction

    Hi all,
    I refer to the following link http://download.oracle.com/docs/cd/E11035_01/wls100/jms/trans.html#wp1035937
    I found that JTA support JMS.
    But I dont' want to use JTA explicitly, I want to use container manage transaction. eg. inside ejb3 stateless session bean.
    does it support JMS?
    With Regards,
    wp

    Hi,
    Yes, WebLogic JMS supports JTA (a.k.a XA, a.k.a global) transactions such as container managed transactions. There are two requirements for CMTs on SSB:
    (1) use an XML descriptor setting or EJB annotation to enable CMT for the SSB
    (2) use a WebLogic JMS connection factory that is configured to have "global (XA) transactions enabled"
    And I usually also recommend:
    (3) Consider using a JEE "res-ref" for the connection factory to enable pooling of JMS resources. See "Enhanced Support for Using WebLogic JMS with EJBs and Servlets" (http://download.oracle.com/docs/cd/E14571_01/web.1111/e13727/j2ee.htm#g1329180), and the "Integrating Remote JMS Providers" FAQ (http://download.oracle.com/docs/cd/E14571_01/web.1111/e13727/interop.htm#JMSPG553).
    (4) Avoid using SSBs to receive messages. MDBs are specifically designed for processing incoming messages.
    It's also possible to have WebLogic automatically enlist foreign (non-WebLogic) vendors in WebLogic transactions. See the "Integrating Remote JMS Providers" FAQ for details (http://download.oracle.com/docs/cd/E14571_01/web.1111/e13727/interop.htm#JMSPG553).
    Regards,
    tom

  • JTA Container Managed Transaction Demarcation question?

    Hello, there is something I'm not quite sure about, concerning JTA Container managed transaction
    I have a remote stateful session bean with a method f().
    the method f() calls the methods g() and h() residing in a different stateless local bean DBLocalBean.
    (DBLocalBean only deals with database calls using the EntityManager)
    I would like to know where the commit is being executed? after f() or after g() and h()

    Hi Meir,
    It depends on the exact settings of the container managed transaction attributes. The most typical (and default) transaction attribute is TX_REQUIRED. TX_REQUIRED means that when a business method invocation arrives the container will either a) import any existing propagated client transaction context or b) if one is not available, start a new transaction.
    Assuming TX_REQUIRED for the three business methods in your example, the container would start a new transaction before invoking f() . Both g() and h() would execute in that same transaction since f's transaction would propagate to them. Finally, after f() returns, the container would commit the transaction it started.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can i user UserTransaction  in a Container-managed transaction Bean

    can i use UserTransaction to control transaction boundaries in a container-managed transaction bean method?
    below is the method:
    there is one-to-many between Employees and SalaryItem
    @TransactionAttribute(value = TransactionAttributeType.REQUIRED)
    private void initEmployeesSalary(Long salarySumId) {
    for(Employees employees: liEmployees){
    for (int i = 0; i < 20; i++) {                                                           
    SalaryItem item = new SalaryDetailItem();
    employees.addSalaryItem(item);
    when there are about 1000 employees,the method run very slow.
    What do you think I should do?
    null

    Hi again,
    The EJB specs say that a stateful Session Bean with CMT is NOT allowed to use the UserTransaction; see page 361 of the EJB2.0 specification. So combining them will not (or should not) work.
    I suggest CMT+SessionSynchronization combined with using a flag to indicate whether notify should be called or not. Otherwise, you could try splitting up the bean into two beans: one with CMT and another one without. The one without CMT could use the UserTransaction and notify.
    Also, you might want to check http://www.onjava.com/pub/a/onjava/2001/10/02/ejb.html
    Hope that helps a bit,
    Guy
    http://www.atomikos.com

  • Executing SQL statements in container managed transactions

    I have a problem when using TopLink 9.0.3 with WebSphere 4, Oracle 9i and J2EE container managed transactions.
    The data changing SQL statements are executed at the end of the (container managed) transaction, not at the time of the calls to UnitOfWork.registerNewObjekt(),
    UnitOfWork.validate...() or UnitOfWork.commit...().
    UnitOfWork(2035008996)--validate object space.
    UnitOfWork(2035008996)--validate cache.
    UnitOfWork(2035008996)--JTS#beforeCompletion()
    UnitOfWork(2035008996)--Connection(398132708)--INSERT INTO SVM_PERSONEN (FAX, NAME, ID, [...]) VALUES ([...])
    UnitOfWork(2035008996)--JTS#afterCompletion(org.omg.CosTransactions.Status._StatusRolledBack=4)
    UnitOfWork(2035008996)--release unit of work
    But the end of the transaction is out of the application server code. The transaction ends after the invoke of the applixcation server method, as the stack trace of an occurring exception shows:
    remote exception
    javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 0 No; nested exception is:
         org.omg.CORBA.TRANSACTION_ROLLEDBACK:
    org.omg.CORBA.TRANSACTION_ROLLEDBACK: com.ibm.websphere.csi.CSITransactionRolledbackException:
         at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:194)
         at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:67)
         at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:414)
         at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:1818)
         at de.gedas.svm.server.app.ejb.EJSRemoteStatelessNavigationEJB.findPersonenZulieferer(EJSRemoteStatelessNavigationEJB.java:964)
         at de.gedas.svm.server.app.ejb._EJSRemoteStatelessNavigationEJB_Tie._invoke(_EJSRemoteStatelessNavigationEJB_Tie.java:589)
         at com.ibm.CORBA.iiop.ExtendedServerDelegate.dispatch(ExtendedServerDelegate.java:506)
         at com.ibm.CORBA.iiop.ORB.process(ORB.java:2376)
         at com.ibm.CORBA.iiop.OrbWorker.run(OrbWorker.java:186)
         at com.ibm.ejs.oa.pool.ThreadPool$PooledWorker.run(ThreadPool.java:104)
         at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)
    So the application server code has no possiblity for special reaction to this error condition.
    How can I use TopLink to execute my SQL statement immidately, not at the the end of the transaction (which is out of the area of my code)? Only the transaction should end at the usual time, managed by the container.

    I don't think there is anyway to currently do this in a JTS managed environment, to handle the exceptions you could,
    - Make use of TopLink session ExceptionHandlers to handle the database errors during the JTS commit.
    i.e.
    uow.setExceptionHandler(yourExceptionHandler);
    or,
    - Let TopLink control the transactions instead of JTS.

  • Container-Managed Transaction Type Attributes not working as expected

    I am having a problem with the container-managed transactions not working as expected. I have 2 methods that work as follows:
    MethodA{
    for(a lot)
    call MethodB;
    @Transaction Type = RequiresNew
    MethodB{
    EntityManager Persist to database
    I want the code in MethodB to be committed to the database when methodB returns. The problem is that I am running out of memory and MethodA is failing. When methodA fails after numerous calls to MethodB nothing is persisted to the database.
    It is my understanding that when using requires new transactions that a new transaction is started for each call to the method and ends when the method returns while the calling method transaction is suspended.
    How am I misunderstanding the requiresNew transaction attribute. What can I do to make a batch insert into my database that will not run out of memory (commit when a methodB returns)?
    Thanks in advance.

    The problem is that EJB invocation semantics for security, container-managed transactions, etc.
    only apply when an invocation is made through an EJB reference. In your case, you are directly
    invoking the implementation method from within the bean. The EJB container has no idea that's
    happening. It's no different than invoking a utility method.
    In order to get the behavior you'd like, you need to retrieve a reference to your own bean and invoke
    through that. You can use SessionContext.getBusinessObject() to get the EJB reference for the
    business interface through which the method in question is exposed.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Refresh object in container managed transaction

    i am using container managed transactions on my ejbs which in turn invoke toplink persistence services. consider the scenario where a record which is inserted has its primary key - a sequence generated number. i want to return this id to the calling module after committing. but as this is a CMT case, the commit doesn't really happen on uow.commit() and thus the object that i return back doesn't have the primary key.
    in a two-tier scenario, i find that the primary key is available right after commit for obvious reasons.
    is there a way to achieve this. how do i return the primary key or even the whole object about to be inserted to the caller ???

    I am assuming you are mapping POJO and not entity beans.
    The UnitOfWork has API that allows you to have the PK sequence values assigned prior to commit.
    UnitOfWork.assignSequenceNumber(Object)
    http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10491/oracle/toplink/sessions/UnitOfWork.html#assignSequenceNumber(java.lang.Object)
    UnitOfWork.assignSequenceNumbers()
    I hope this addresses your issue.
    Doug

  • Log the Container managed Transaction ID

    Can I somehow log the Container managed Transaction ID (or some transaction
              identifier) for the method (when I encounter some problems and I am debuging
              it) or how do I get a reference to the TransactionManager object inside the
              weblogic server to fetch it.
              

    What version of WLS are you using?
              WLS 6 lets you get a reference to the TransactionManager or the current
              transaction. Take a look at the JTA docs for more info.
              -- Rob
              Stefan Tamasi wrote:
              >
              > Can I somehow log the Container managed Transaction ID (or some transaction
              > identifier) for the method (when I encounter some problems and I am debuging
              > it) or how do I get a reference to the TransactionManager object inside the
              > weblogic server to fetch it.
              Coming Soon: Building J2EE Applications & BEA WebLogic Server
              by Michael Girdley, Rob Woollen, and Sandra Emerson
              http://learnweblogic.com
              

  • Entity Bean can only use container-managed transaction demarcation?

    In <<Designing Enterprise Application with J2EE 2nd>>
    Section 2.3.3.3 Enterprise Bean Transactions,it says:Entity beans can only use container-managed transaction demarcation.
    That means,i can not get UserTransaction from EJBContext.
    Is that true?

    Yes this is the requirement of the specs. Your ejb code generator should give you the error if you use usertransaction.
    --Ashwani                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Mountain Lion install results in blank gray screen.

    I recently downloaded and installed Mountain Lion on my wife's late-2007 iMac.  Unfortunately, each time, after the installer finishes and reboots, the computer sticks at a blank gray screen where normally the Apple logo would appear while things boo

  • Lost Doc IN Word for Mac '04

    Lat week I found out I had a bad dose of ID Theft so since last Wed I've made over 37 calls to various entities & institutions 5 or 6 pages in Microsoft word, date & time on each entry This am was typing away as I was talking to Dallas Police for 5th

  • Firefox Crashes - Too Many Bookmarks

    I have over 100,000 bookmarks of research. Firefox Home Screen goes black after a few minutes of attempting to sync bookmarks for the first time on device. I am using a iPhone 3GS with iOS 4. When I reduce the nuber, which I should not have to and pr

  • Want to organize library by "album", not "album by year"

    I had my library organized by "album". I closed itunes, started back up, and now it appears as "album by year" (even though the right-click drop down menu lists it as just "album". I have tried closing itunes, restarting the computer, and downloading

  • High Def Podcasts and the Classic

    I recently downloaded 2 High Def Podcasts and then converted them to "iPod viewing". The last message I recieve when syncing my Classic is that it cannot moved these HD Podcasts over. Anyone else have a similar issue or know how to tell if the podcas