HeuristicMixedException with usertransactions

Hi,
I'm testing distributed EJB configuration with two Weblogic 6.1's in different
computers, A and B. A has some simple test JSP's which call the EJB's on B. B
is Windows 2000 with the EJB's and data source to Oracle 9.2, drivers oci920_8.
When I attempt to use UserTransactions in the JSP page as in:
     Context ctx = getRemoteContext();
     UserTransaction tx = (UserTransaction) ctx.lookup
          ("javax.transaction.UserTransaction");
     tx.begin();
// ..... get the EJB and call several methods ....
     tx.commit();
I get the exception:
Stacktrace = javax.transaction.HeuristicMixedException at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:237)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:190)
at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:247)
at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:240)
at jsp_servlet._distributed_ejb.__recordList._jspService(__recordList.java:257)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:304)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2495)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2204)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
When I do not use UserTransactions and let each EJB method call be in it's own,
container-initiated transaction the code works OK, but that's not what I want
to test.
getRemoteContext() is normal (?):
static Context getRemoteContext() throws Exception {
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, SERVER_B_URL);
h.put(Context.SECURITY_PRINCIPAL, USER);
h.put(Context.SECURITY_CREDENTIALS, PASS);
return new InitialContext(h);

Hi,
We've had similar problems with WL 6.x when calling different non clustered
WL ejb servers.
I know for sure that two-phase commit was broken at some pint in WL6 (might
have been fixed in a patch or service pack).
Also, you need to use distinct domain names when you connect from one server
to another. I remember using the same domain name was triggering the same
exception you are seeing (we're using WL7 now).
Alex.
"Janne" <[email protected]> wrote in message
news:[email protected]...
>
Hi,
I'm testing distributed EJB configuration with two Weblogic 6.1's indifferent
computers, A and B. A has some simple test JSP's which call the EJB's onB. B
is Windows 2000 with the EJB's and data source to Oracle 9.2, driversoci920_8.
When I attempt to use UserTransactions in the JSP page as in:
Context ctx = getRemoteContext();
UserTransaction tx = (UserTransaction) ctx.lookup
("javax.transaction.UserTransaction");
tx.begin();
// ..... get the EJB and call several methods ....
tx.commit();
I get the exception:
Stacktrace = javax.transaction.HeuristicMixedException atweblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTra
nsactionImpl.java:237)
atweblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransaction
Impl.java:190)
atweblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManag
erImpl.java:247)
atweblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManag
erImpl.java:240)
atjsp_servlet._distributed_ejb.__recordList._jspService(__recordList.java:257)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27) atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:265)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:304)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:200)
atweblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:2495)
atweblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:2204)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) atweblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
>
When I do not use UserTransactions and let each EJB method call be in it'sown,
container-initiated transaction the code works OK, but that's not what Iwant
to test.
getRemoteContext() is normal (?):
static Context getRemoteContext() throws Exception {
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, SERVER_B_URL);
h.put(Context.SECURITY_PRINCIPAL, USER);
h.put(Context.SECURITY_CREDENTIALS, PASS);
return new InitialContext(h);

Similar Messages

  • Transaction demarcation with UserTransaction

    Hi
    Can any one explain, How does UserTransaction used for Bean Managed Transaction works with multiple resource managers and if in this case resources should be enabled for Two phase commit protocol?
    Thanks

    Java EE requires JTA. It's the JTA implementation in the application server that allows the work performed by multiple resource managers
    in a transaction to have ACID properties. At the application level there's nothing special you need to do. It should all just be handled by the container.
    From a deployment and server configuration perspective the requirements can differ depending on the implementation so ultimately you'd need to consult your vendor's documentation. Typically the main thing to ensure is that each resource (JDBC datasource, JMS connection factory, etc.) supports the ability to participate in 2-phase commit. For JDBC drivers, this is often designated by configuring an "XA"-capable driver.

  • HeuristicMixedException on VMS with 6.1sp2

    Has anyone using VMS encountered the random unexplained
    javax.transaction.HeuristicMixedException with 6.1sp2 that was
    suppose to have been fixed in 6.1sp3.
    http://e-docs.bea.com/wls/docs61/notes/bugfixes2.html#1147388
    "064232,The javax.transaction.HeuristicMixedException is no
    longer being thrown sporadically at commit."
    I ask because there is not currently a 6.1ps3 release for VMS, we are looking
    to port from Sun, and we had this HeuristicMixedException regularly on Sun.

    Hi Paul,
    this is how I got Cocoon 2.0.4 running on WLS 6.1.4
    (Download the Cocoon source from http://xml.apache.org/cocoon/dist/)
    Remove all but the following JARs from lib/optional
    commons-jxpath-1.0.jar
    jing-20020724.jar
    resolver-20020130.jar
    servlet_2_2.jar
    commons-logging-1.0.jar
    jtidy-04aug2000r7-dev.jar
    rhino-1.5r3.jar
    xt-19991105.jar
    Update lib/jars.xml to reflect these changes
    build clean
    build webapp -Dinclude.webapp.libs=yes
    Copy the following JARs to a suitable lib-directory:
    xercesImpl-2.0.0.jar
    xml-apis.jar
    xalan-2.3.1.jar
    xt-19991105.jar:
    java/lib/tools.jar
    Deploy the resluting cocoon.war and you should have a Cocoon up and running that
    can do the XML->HTML Hello World sample. The status page works fine too.
    If you need a more competent Cocoon, try adding the required JARs on the class
    path (or add them the to your webapp-build if you are confident that WLS are capable
    of handling their manifests).
    Good luck
    /Peter
    "Paul Lee" <[email protected]> wrote:
    >
    Hi all, forgive me if this is not the right "Install" forum, but I am
    looking for
    some pointers/success stories in running Cocoon 2 with WLS 6.1 SP2 (Solaris
    preferably).
    I have followed the official installation instructions from Cocoon and
    searched
    the weblogic newsgroups, but none of them worked. Perhaps none of them
    were specifically
    about 6.1sp2.
    If anyone has any advice or pointers it would be greatly appreciated.
    Thanks,
    Paul

  • OK, very close to integrating WL8.1/TL/UserTransactions...  Please help!

    OK, I'm nearly there. I can create my UserTransaction, query from a ClientSession, use getActiveUnitOfWork from my ClientSession, BUT when I commit the UserTransaction, NOTHING goes back to the database, and no errors are thrown.
    And I'm not commit()-ing on the UnitOfWork.
    here's the portion of the low which shows the UserTransaction commit:
    message: Obtain and begin a javax.transaction.UserTransaction: 9061763 for DAOImpl: 8184738
    ServerSession(25450642)--client acquired
    ClientSession(3755648)--acquire unit of work: 19483635
    UnitOfWork(19483635)--JTS register
    2004-10-08 00:59:14,734 DEBUG com.emc.km.dao.toplink.DAOImpl - method: close
    message: Commit the javax.transaction.UserTransaction: 9061763 for DAOImpl: 8184738
    UnitOfWork(19483635)--Before JTS Completion
    UnitOfWork(19483635)--After JTS Completion
    UnitOfWork(19483635)--release unit of work
    ClientSession(3755648)--client released
    ClientSession(8184738)--client released
    ServerSession(25450642)--client acquired
    I'm using the:
    server.setExternalTransactionController(new WebLogicJTSExternalTransactionController());
    setup and I've got my session.xml setup for External Transaction Controller = true.
    Please help, I'm stumped!
    Thanks!

    I don't know if you will find this helpful because I am working with WebSphere 5.0/Toplink 9.0.4.4.
    I do believe you have to commit the unit of work. The unit of work is supposed to know the current UserTransaction state and should determine whether to perform the commit or not.
    For reference, I have been able to integrate with UserTransactions successfully. My code has the following characteristics:
    - The client session is retrieved from the Server object using acquireClientSession()
    - The unit of work is retrieved using acquireUnitOfWork() on the client session.
    - I DO call commit() on the unit of work when I am done with my updates (your email indicated you were not committing?)
    The work is not committed to the database until UserTransaction.commit() is invoked. I verified this in the debugger by stepping through.
    The integration works better than I expected, because the UnitOfWork determines at commit time whether it is controlling the transaction or not. At least it behaves that way. If my code starts a UserTransaction before creating the unit of work, it waits for my code to commit. If my code does not start, the UnitOfWork commits itself.
    I hope this helps.
    -John

  • Weblogic5.1, Transaction involving SQL Svr and AS400/DB2

              Hi, after reading quite a few posts regarding this issue I believe to demarcate a
              transaction involving SQL Server and AS400/DB2 is not impossible. But we have to
              handle the rollback and other stuff on our own. Am I correct? Is there any hack around
              this?
              I've tried to use an EJB(ejbY) that will insert a record in AS400/DB2 and subsequently
              in ejbY, I invoke another EJB(ejbX) that reside in another WL5.1 to insert a record
              in SQL Server. Of course this is demarcated with UserTransaction. Technically is
              this possible? This is because I've encountered some exceptions with this hack and
              would like to seek some advise.
              Thanks.
              [apps.zip]
              

    Hi,
      If you have access to My Oracle Support then have a look at this note -
    How To Migrate Non-Oracle Databases For Which a SQL*Developer or Migration Workbench Option Is Not Available (Doc ID 393760.1)
    Regards,
    Mike

  • Can I use UserTransaction within a CMP Session bean?

    Basically the problem is as follow:
    I have the following method in a Statefull session bean:
    public Whatever do()
    processSomething();
    notify();
    the notify() basically notifying the client that then query for the something that was processed in the processSomething() method.
    THE PROBLEM is that the changes have not been committed yet as the do() method is not finished yet and the container has not committed the changes.
    THE QUESTION is - can I use UserTransaction inside
    processSomething to commit the changes and leave the bean as CMP? I want to leave it as CMP as there are more methods on the bean and I don't want to have to manage the transactions for them.
    Anyone has any other ideas?
    Thanks in advanced.

    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

  • EJB 2.1 Timer bean using CMT (WAS 6.0) with Toplink 10.1.3

    I have a timer bean that is calling a toplink transaction. The timer bean uses CMT with a "RequiresNew" transaction attribute. The ejbTimeout() method of the bean calls a toplink transaction - this transaction includes code to do uow.commit().
    I am using the external transaction controller. Here is the relevant portion of the sessions.xml file:
    <login>
    <datasource>jdbc/XvsOMDataSource</datasource>
    <platform-class>oracle.toplink.oraclespecific.Oracle9Platform</platform-class>
    <uses-external-connection-pool>true</uses-external-connection-pool>
    <uses-external-transaction-controller>true</uses-external-transaction-controller>
    </login>
    <external-transaction-controller-class>com.ford.it.persistence.impl.toplink.JTSExternalTransactionControllerExtended_WAS6</external-transaction-controller-class>
    When the uow.commit is being executed, Toplink tries to get the UserTransaction but since the code has been invoked by a CMT EJB - access to the UserTransaction is not allowed and my transaction fails as follows:
    [7/19/06 7:46:30:539 EDT] 00000048 TransactionHe E com.ford.it.persistence.impl.toplink.TransactionHelper getUserTransaction Cannot obtain UserTransaction from JNDI. <javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".>javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
    If I don't use the external transaction controller, the transaction again fails on uow.commit() - saying that Connection.commit() cannot be explicitly called, since it is part of a global transaction.
    All I want, is for Toplink to just fire the SQL during uow.commit() (without issuing a Connection.commit()) - the CMT timer bean will take care of the Connection.commit.
    Any thoughts on how to resolve this issue?
    Prabodh.

    The problem has been resolved. It was a usage-related issue. Thank you all.

  • How to use UserTransaction in non-EJB code

    This is in a class that is called from within a Stateless Session bean. In this class, I'm trying to use a UserTransaction object that is created as follows (taken from Zuffoletto's book):
    ========================================
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    ctx = new InitialContext(env);
    tx = (UserTransaction) ctx.lookup("javax.transaction.UserTransaction");
    ========================================
    However, when I call tx.begin(), it throws an exception as follows:
    ========================================
    javax.transaction.NotSupportedException: Another transaction is associated with this thread. Existing transaction Name=[EJB com.bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke
    (com.bea.wlw.runtime.core.request.Request)],Xid=BEA1-001123C02690(16658514),Status=Ac
    tive,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=13,seconds left=43187,activeThread=Thread[ExecuteThread: '12' for
    queue: 'weblogic.kernel.Default',5,Thread Group for Queue: 'weblogic.kernel.Default'],SCInfo[workshop+cgServer]=
    (state=active),properties=({weblogic.transaction.name=
    [EJB com.bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke
    (com.bea.wlw.runtime.core.request.Request)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=
    (CoordinatorURL=cgServer+192.168.0.73:7001+workshop+t3+, XAResources={},NonXAResources={})])
    ========================================
    Any ideas/suggestions/hints??
    Why would this explicitly created tx, being used by one single call be colliding with an existing transaction?
    Thanks for your comments.

    Hello,
    As I understand, you would like to setup a watch folder which will be getting pdf files in arbitrary intervals. You then want each pdf to be converted to ps in a separate folder.
    You could achieve this with the help of a script by polling for pdf files present in the watch folder. When you find pdf files, convert them to ps, save the ps file in another folder and then move the pdf to another folder.
    In any case, once the process of conversion of pdf to ps is over, acroread will quit.
    There is no way to keep the acroread process running in background and convert pdfs as and when they are available.
    Please let me know if this answers your query.
    Regards,
    Rishi

  • Bean-managed transaction with EJB 3.0

    Hi,
    I try to get a bean-managed transaction example running with EJB 3.0 under GlassFish v2ur2.
    In order to demarcate the scenario I have to get me the UserTransaction which I get from the SessionContext. I would like to use it then like: UserTransaction ut = context.getUserTransaction();
    I tried to get the SessionContext with the help of the EJB method setSessionContext which should be called by the container after instance creation.
    However, setting a log output into that method does not show any call of this method.
    So, how can I get this method called or is there another way to get the SessionContext for the UserTransaction to work ?
    Are there any good and fully implemented examples for bean-managed transactions ?
    Thanks for your help.
    Regards

    I found the solution for that my SessionContext was NULL and I could not use the UserTransaction.
    The reason for it is that I injected the EJB with @EJB into my servlet and did a MyBean mybean = new MyBean();
    That leads to a SessionContext which is NULL within my EJB.
    If I use it without instantiating it it works fine.
    Again, thanks for your help. At least it pointed me into the right direction.
    Regards

  • Setting Isolation Level In A UserTransaction

    We are having a problem where a class creates a UserTransaction from the InitialContext,
    but does not see any database changes made by other EJBs even though they have
    been committed. This "seems" like an isolation issue.
    What is the default isolation level for UserTransaction? And since it appears
    that it is not seeing committed data, what level should it be set to? (i.e. TRANSACTION_READ_COMMITTED
    would be nice...)

    this is mirrored from the transaction newsgroup:
    Joseph Weinstein <[email protected]> wrote:
    >
    >
    Interesting, but it's not an isolation level issue. There is no DBMS
    isolation level
    that could cause a user not to see already-committed data.Well, we are using Oracle as our backend and it supports Read Uncommitted, Read
    Committed and Serializable. The Serializable option would prevent a transaction
    from seeing any committed data to a table (i.e. prevents unrepeatable reads).
    The default isolation level of most DBMSes is READ_COMMITTED, and you
    should
    never have to change it, and you should be able to see already-committed
    data.I agree, but that is not happening for us (and this gets somewhat complicated
    with JMS). What is Weblogic 8.1's default isolation level for any transaction.
    From the link below, I get the impression it is SERIALIZABLE which would explain
    the behaviour I'm seeing. Athough the article seems to be talking about CMT (container
    transation), I would suspect a BMT (bean managed transaction) be similar (just
    manual).
    If this only confuses things, please let me know the easiest way to communicate
    this issue (code, etc..)
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.developer.interest.transaction&item=227&utag
    (from the article)
    Subject: Re: What is ths default transaction isolation level
    Date: Mon, 12 Feb 2001 15:27:24 -0500
    From: "Cameron Purdy" <[email protected]>
    Organization: BEA SYSTEMS Inc
    Newsgroup: weblogic.developer.interest.transaction
    serializable
    -- Cameron Purdy Tangosol, Inc. http://www.tangosol.com +1.617.623.5782 WebLogic
    Consulting Available
    "mrityunjay" <[email protected]> wrote in message news:3a86c781$[email protected]..
    Hi , > If transaction isolation , for a EJB is not specified what is the > defaulttransaction isolation level > Thanks > Jay > >

  • How to insert multiple rows in the database table with the high performance

    Hello everybody,
    I am using the struts,jsp and spring framework. In my application there are 100s of rows i have to insert into the database 1 by 1. I am using usertransaction all other things are working right but i am not getting the real time performance.
    Can anyone tell me the proper method to insert multiple records and also with fast speed

    I don't know much about Spring etc, but if the jdbc Statemenet.addBatch(), Statement.executeBatch() statements let you bundle a whole lot of sql commands into one lump to execute.
    Might help a bit...

  • UserTransaction error Message

              I used to UserTransaction with Stateful Session Bean.
              I obtained to UserTransaction object in client applications with folow next :
              Context jndiTran = new InitialContext();
              UserTransaction userTran = (UserTransaction)jndiTran.lookup("java:comp/UserTransaction");
              userTran.begin();
              but, I discovered to error message with follow next :
              I want to know why NullPointException was thrown and how to way it.
              thank you.
              "java.lang.NullPointerException
              at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyCo
              ntextWrapper.java:29)
              at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.j
              ava:117)
              at javax.naming.InitialContext.lookup(InitialContext.java:350)
              at jsp_servlet._work_flow._cabin_insert_sf._jspService(_cabin_insert_sf.
              java:99)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              pl.java:106)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:907)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:851)
              at weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
              ContextManager.java:252)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
              a:364)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:252)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)"
              

    That looks like a bug. Please report it to [email protected]. Also, make sure that you are
              running the latest service pack. (It may already be fixed.)
              I suspect that if you lookup "javax.transaction.UserTransaction" that it will work fine.
              -- Rob
              "Kyoung hee, Kim" wrote:
              > I used to UserTransaction with Stateful Session Bean.
              > I obtained to UserTransaction object in client applications with folow next :
              > ..
              > Context jndiTran = new InitialContext();
              > UserTransaction userTran = (UserTransaction)jndiTran.lookup("java:comp/UserTransaction");
              > userTran.begin();
              > ..
              >
              > but, I discovered to error message with follow next :
              > I want to know why NullPointException was thrown and how to way it.
              > thank you.
              >
              > "java.lang.NullPointerException
              > at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyCo
              > ntextWrapper.java:29)
              > at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.j
              > ava:117)
              > at javax.naming.InitialContext.lookup(InitialContext.java:350)
              > at jsp_servlet._work_flow._cabin_insert_sf._jspService(_cabin_insert_sf.
              > java:99)
              > at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              > at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              > pl.java:106)
              > at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              > textImpl.java:907)
              > at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              > textImpl.java:851)
              > at weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
              > ContextManager.java:252)
              > at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
              > a:364)
              > at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:252)
              >
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)"
              

  • How to get transacted session in direct mode with jmsra adapter

    Hi,
    I use MQ 4.4u1 release with GF in EMBEDDED mode. I configured several connection factories with NoTransaction/LocalTransaction/XATransaction support. In my app I get a connection factory from JNDI tree, create connection/session/producer and send several messages to queue. Everything works fine when I don't use transactions. But, when I want to send messages in one transaction, the connection always provided to me non-transacted session. The session created via
    Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
    request. I check the session transacted state and acknowledge mode right after i get it:
    log.fine("Session: " + session + "; transacted: " + session.getTransacted() + "; ackMode: " + session.getAcknowledgeMode());
    The log shows me that the session is not transacted and ackMode is 0 (DUPS_OK_ACKNOWLEDGE). If I try to commit the session after messages were sent I get the correct exception:
    javax.jms.IllegalStateException: MQJMSRA_DS4001: commit():Illegal for a non-transacted Session:sessionId=3361979872663370240
    Does anyone know how to get transactional session in direct mode?
    Thanks, Denis.

    I mentioned LOCAL because I misread your post and thought you were suggesting that LOCAL mode behaved differently.
    If you want to send messages in a transaction from within a Servlet then I think you're expected to use a UserTransaction: Here's an example that worked for me:
            Connection connection = outboundConnectionFactory.createConnection();
            Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
            userTransaction.begin();
            MessageProducer producer = session.createProducer(outboundQueue);
            int numberOfMessages = 10;
            for (int i = 0; i<numberOfMessages; i++) {
                Message message = session.createTextMessage("Hello world");
                producer.send(message);
            userTransaction.commit();
            connection.close();I obtained the UserTransaction with this resource declaration:
        @Resource(name = "java:comp/UserTransaction")
        private UserTransaction userTransaction;The EJB spec explicitly states that local transactions aren't supported in EJBs; I haven't found such an explicit statement for Servlets but suspect that JMSRA is taking the same approach.
    As for imq.jmsra.direct.disableCM property - this appears to disable connection pooling and from your post changes other behaviour as well. How did you find out about it (other than by examining the code)? As far as I can see this is not a documented feature and is not necessarily tested or supported.

  • Issue with JMS XAQueueSession

    My Application Server is SAP NetWeaver Application Server CE7.1
    While I'm creating XAQueueSession and publishing, the messages are not published into the queue.
    Is there any error in my code?
    public class JMSSender extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
       static final long serialVersionUID = 1L;
            PrintWriter out;
            private XAQueueConnectionFactory queueConnectionFactory;
         private Queue queue;     
         private QueueSession queueSession = null;
         private QueueSender queueSender = null;
         private TextMessage message = null;
         private XAQueueSession queueSessionXA = null;
         private XAQueueConnection queueConnection = null;
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              out = response.getWriter();
              try {
                   initQueue();
                   printQueue("Q Before");
                   publishMessage(false);
              } catch (Exception e) {
                   e.printStackTrace(out);
              } finally {
                   printQueue("Finally");
                   closeJMS();
         public void publishMessage(boolean rollBackFlag) throws Exception {
              int rand = new Random(100).nextInt();
              for ( int i = 1; i < 5; i++) {
                 message = queueSession.createTextMessage();
                  message.setText("Current Time is (" + (new Date().getTime() + rand + i) + ") :: " + new Date());
                  out.println("<br>" + "Sending message :: " + message.getText());
                  queueSender.send(message);
                  if (rollBackFlag && (i == 3)) {
                       throw new Exception("Throwing Exception");
         private void closeJMS() {
              try {
                   if (queueSession != null) {
                        queueSession.close();
                   if (queueSessionXA != null) {
                        queueSessionXA.close();
                   if (queueConnection != null) {
                        queueConnection.close();
              } catch (Exception e) {
                   out.println("<br>");
                   e.printStackTrace(out);
         public void printQueue(String desc) {
              try {
                   out.println( "<br>" + desc + " Queue contents :: " );
                   QueueBrowser browser = queueSession.createBrowser(queue);
                   Enumeration<TextMessage> en = browser.getEnumeration();
                   while (en.hasMoreElements()) {
                     TextMessage queueBrMessage = en.nextElement();
                      out .println( "<br>" + queueBrMessage.getText());
              } catch (JMSException e) {
                   out.println("<br>");
                   e.printStackTrace(out);
         public void initQueue() throws Exception {
              InitialContext ctx = getInitialContext();
              queueConnectionFactory = (XAQueueConnectionFactory) ctx.lookup("jmsfactory/default/VQConFactoryXA");
              queue = (Queue) ctx.lookup("jmsqueues/default/VQueue");
              queueConnection = queueConnectionFactory.createXAQueueConnection();
              queueSessionXA = queueConnection.createXAQueueSession();
              queueSession = queueSessionXA.getQueueSession();
              queueSender = queueSession.createSender(queue);
              queueConnection.start();
         public InitialContext getInitialContext() throws Exception {
              Properties properties = new Properties();
              properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
              properties.put(Context.PROVIDER_URL, "localhost:50004");
              properties.put(Context.SECURITY_PRINCIPAL, "Administrator");
              properties.put(Context.SECURITY_CREDENTIALS, "atlas123");
              properties.put("force_remote", "true");
              InitialContext context = new InitialContext(properties);
              return context;
    }

    Don't attempt to use the XAConnection and XASession interfaces directly. These are intended for internal use by the application server or resource adapter.
    See the javadoc for XAConnection: "This interface is for use by JMS providers to support transactional environments. Client programs are strongly encouraged to use the transactional support available in their environment, rather than use these XA interfaces directly. " ( http://java.sun.com/javaee/6/docs/api/javax/jms/XAConnection.html )
    Your earlier attempts were closer to the mark. The standard way to do this in JavaEE is to start a UserTransaction, look up a javax.jms.Connection from JNDI (which should be a JMS connection wrapped by a JCA resource adapter), create what appears to be a non-transacted session and use it to send and receive messages, and, at the end, commit the UserTransaction. Even though it doesn't look like it, because you're using a resource adapter the work is performed in an XA transaction. The resource adapter takes care of the complexities of XA, such as enlisting and delisting the XA resource, handling XIDs, etc.
    You're using NetWeaver. I'm not familiar with that. if any NetWeaver experts are reading this, please do join in. So I don't know whether NetWeaver provide a JCA resource adapter for JMS and, if so, how to configure it. There's a general section on resource adapters in the NetWeaver docs.
    I read that NetWeaver stores messages in a database. If your application is updating the same database directly you can achieve the same effect as an XA transaction by using the same underlying database connection for both. The NetWeaver docs describe how to configure this. Note that since this is a specific feature of NetWeaver, if you choose this approach this forum is probably not the best place to look for help.
    Hope this helps...
    Nigel

  • Losing UserTransaction state in Stateful session bean

    I have a UserTransaction I wish to begin and commit in different methods of a Stateful session bean. I have 2 methods to test this on the session bean:
    public void beginTransaction()
    trans = context.getUserTransaction() ;
    trans.begin() ;
    public void commitTransaction()
    trans = context.getUserTransaction() ;
    trans.commit() ;
    If I call these methods from one Perform method in a Struts action all works fine. If I call the methods in different Struts actions (storing the session bean handle on the HTTPSession in the first for retrieval in the second) the second call fails with the following exception:
    java.lang.IllegalStateException: No active Transaction
    The state of the transaction on the second call is STATUS_NO_TRANSACTION. I am certain that I have lost no state on the session bean and that using handles gives me the correct bean since I have written some state to test this. Basically something seems to close the transaction between the end of the first Perform method and the beginning of the second (I am of course assuming this is a valid thing to do).
    My session bean descriptor has <transaction-type>Bean</transaction-type>, and I am using OC4J.
    If anyone can point out what it is I am doing wrong I would be grateful!
    James.

    Sorry, I have re-checked my code and I believe I found the problem.
    I was beginning my transaction inside ejbCreate() and trying to commit/rollback in another method. This works in JBoss 3.2 but does not work in either OC4J or WebLogic 7.
    If I begin my transaction in a business method and commit/rollback in another method, everything works fine. (It also seems to work fine in 9.0.3 this way).
    So I am not sure whether this is a bug in 9iAS/WLS, or a bug in JBoss, or something that is left "vague" in the J2EE spec. Unfortunately, examples on bean-managed transactions are thin on the ground generally (the usual advice being not to use them, which I definitely agree with!).
    If you believe that the behaviour I describe is a bug in 9iAS, I can send a simple EJB test case.
    Keith

Maybe you are looking for