Results 1 to 6 of 6

Thread: Transaction error help

  1. #1
    Join Date
    Apr 2007
    Posts
    21

    Default Transaction error help

    Hi,

    I have a business object whose methods I want to execute transactionally, except for one method. The object is proxied by a TransactionProxyFactoryBean declared in the Spring config file. Let us say the object is Foo and the methods are bar0, bar1, bar2, etc. bar0 has the attribute PROPAGATION_NOT_SUPPORTED and the rest of the methods have the attribute PROGAGATION_REQUIRED. bar0 and bar1 read data from the MS SQL Server database db1 and bar2 reads data from the both db1 and another MS SQL Server database db2.

    Now I have this sequence of calls within another object's method:

    Foo foo = .. (get foo bean from the config file)
    foo.bar0();
    foo.bar1();

    Where in Foo, I have

    public void bar0() {
    // Read some data from db1
    ...
    }

    public void bar1() {
    // Read some data from db1
    ....
    this.bar2();
    }

    public void bar2() {
    // Read some data from db1
    ...
    // Read some data from db2
    ...
    }


    In the line where bar2() reads data from db2, I get this exception:

    javax.transaction.xa.XAException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Import of MSDTC transaction failed: Result Code = 0x8004d00e.

    So, the read from the second database fails.
    We have another instance in the application where we read data from the second database using a method with PROPAGATION_NOT_SUPPORTED and it works. The SQL Server seems to be OK.


    So, does anyone know why the transaction would fail in this case?

    Thanks in advance.
    Last edited by imchi; Jul 13th, 2007 at 05:39 PM.

  2. #2
    Join Date
    Jul 2007
    Posts
    6

    Default RE: Transaction error help

    I'm not a Spring expert but perhaps you're creating nested transactions by invoking the bar2 method within the bar1 method. Just a guess.

  3. #3
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    The usual problem of misunderstanding AOP proxies seems not to apply here since bar1() is also transactionally. Have you tried to call bar2() from outside, i.e. foo.bar2()?

    Having a look at what the error message might mean I only found:

    The error message says that SQL Server can not enlist in the transaction that is provide because the transaction is already implicitly or explicitly committed or aborted.
    That might point to an error in the transaction setup, e.g. the transaction gets auto-committed.

    Jörg

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Quote Originally Posted by djheath View Post
    I'm not a Spring expert but perhaps you're creating nested transactions by invoking the bar2 method within the bar1 method. Just a guess.
    As Jörg said, this doesn't actual create another transaction (unless you are using AspectJ). I would turn the logging up and post that, it might provide more clues about what's going on!
    http://static.springframework.org/sp...ng-aop-proxies
    Last edited by karldmoore; Aug 29th, 2007 at 09:59 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #5
    Join Date
    Apr 2007
    Posts
    21

    Default

    Quote Originally Posted by Jörg Heinicke View Post
    The usual problem of misunderstanding AOP proxies seems not to apply here since bar1() is also transactionally. Have you tried to call bar2() from outside, i.e. foo.bar2()?

    Having a look at what the error message might mean I only found:



    That might point to an error in the transaction setup, e.g. the transaction gets auto-committed.

    Jörg
    Thanks for you suggestions. Calling bar2() from outside gives the same error.
    I don't understand this: if this is a read-only operation and I have no previous write operations of that database, why would it matter whether it auto-commits?

  6. #6
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by imchi View Post
    if this is a read-only operation and I have no previous write operations of that database, why would it matter whether it auto-commits?
    It doesn't matter if it was a read-only operation or not. The transaction is committed - and SQLServer complains. But have in mind that this was only a guess. Only you can find out in which state your transaction is when this error occurs.

    Quote Originally Posted by imchi View Post
    Calling bar2() from outside gives the same error.
    That does not really point to such an error though.

    Jörg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •