Announcement Announcement Module
Collapse
No announcement yet.
Distributed transaction & jndi data sources Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Distributed transaction & jndi data sources

    Iím using Spring successfully (via JBoss) so far in doing some transactions to Oracle. Iím now trying to prove a distributed transaction across two Oracle databases, ie 2 data sources and have mimiced the jpetstore example which defines beans of type JndiObjectFactoryBean and JtaTransactionManager with further beans that reference these.

    But when attempting to run I get an exception:
    nested exception is javax.naming.NameNotFoundException: jdbc not bound

    How / when should the binding occur ? Iím missing a trick somewhere Ė can anyone advise ?

    PS Have looked at Tomcat jndi how-to regarding server.xml etc but Tomcat in Jboss has subtle differences because of hot-deploy. Also looked at jboss-web.xml but cant see the solution.

    Also - when searching entire Spring examples for
    jdbc/jpetstore-order it also turns up in web.xml as a <resource-ref>.
    Ok so do this as well but then get jdbc not bound as soon as I try to hot-deploy onto JBoss.

  • #2
    I think you're asking how to set up a JNDI datasource in jboss - if I'm wrong, please excuse me, this will be irrelevant.

    I'm using jboss 3.2.5. The details changed at some point in the 3.x series - I can't remember just when, maybe changing from 3.0.x to 3.2.x

    You need a file calld xxxxxx-ds.xml
    in $JBOSSHOME/server/default/deploy
    (if you're not using default, substitute the appropriate name).
    You can change the xxxxxx, but the file name must end in -ds.xml (possibly -xa-ds.xml for distributed transactions).

    I haven't used distributed transactions, but jboss provides a number of example files in $JBOSSHOME/docs/examples/jca - oracle-xa-ds.xml should get you going in the right direction.

    Hope this helps

    Comment


    • #3
      Chris - thanks for your reply. I should have supplied more background info. I'm using JBoss because I'll be doing some EJB work later but that doesnt come into it right now - my focus is on Spring. I could just take JBoss out of the equation for now and run with Tomcat because the Tomcat docs explain how to set up jndi resources in its server.xml. But Tomcat in JBoss seems to have some differences because of the hot-deploy etc. I could get bogged down in JBoss & Tomcat whereas I'm more interested in trying to prove a Spring distributed transaction.

      Looking back through the forums I found a few references to other people trying to do distributed transactions in Spring and it seems that one needs something else to complete the picture - like JOTM. ie Spring in itself doesnt supply the whole XA transaction story - the JtaTransactionManager forms part of it - I'll need to do some more research.

      Eventually I could be using EJBs but leveraging the Spring transaction approach.

      Spring techs - I'm looking forward to the book because there's not enough in the documentation :wink:

      Comment


      • #4
        It looks from the exception you are getting in your first message that one, or both, of your datasources are not bound to the JNDI. This is usually the responsibility of the application server, hence the first reply to your question. Spring just obtains the datasource(s) it needs from JNDI.

        As for the more general point, yes, Spring does not provide an implementation of distributed transaction manager. This, again, is the responsibility of the app. server. What it does provide is the mechanism to configure your application using various different transaction implementations without having to change your code.

        It the responsibility of the app server to provide the distributed transactions.

        Jonny

        Comment


        • #5
          javascript:emoticon('')
          Sad
          But the essense of what I'm trying to do is to run a distributed transaction without relying on an Application Server - I thought that was where Spring could assist.
          So:
          1) If I wish to run a distributed transaction say using Spring hosted within Tomcat then will JOTM provide the missing bits (ie the distributed transaction manager) ?

          2) If I wish to run a distributed transaction say using Spring hosted within JBoss can I use JBoss distributed transaction manager (I presume it has one) without resorting to EJB ?

          Does anyone know of any 'cookbook recipes' for setting up either of these in conjunction with Spring ?

          Thanks for advice so far - any help appreciated

          Comment


          • #6
            Well, having to use distributed transactions is something I would rely on the application server for. I'm using Jonas, not JBoss, but Jonas can be configured to use just the services you require. The transaction manager (which is JOTM) can be set up without having to set up an ejb container for example. It wouldn't suprise me if JBoss has similar abilities to just configure the services you need.

            I now view Jonas as an platform that integrates together the various j2ee technologies and I can pick and choose which I need. If you go it alone and get Tomcat with JNDI and integrate JOTM you're more or less doing the same thing these guys did. Then, if you find you need JMS, for example, you'd have to do that integration whereas in a configurable server it's just a matter of turning it on and configuration.

            Now, about the dist. transactions. You can use the transaction manager of the underlying j2ee container by using org.springframework.transaction.jta.JtaTransaction Manager. No need to use EJBs.




            Originally posted by tntpro
            javascript:emoticon('')
            Sad
            But the essense of what I'm trying to do is to run a distributed transaction without relying on an Application Server - I thought that was where Spring could assist.
            So:
            1) If I wish to run a distributed transaction say using Spring hosted within Tomcat then will JOTM provide the missing bits (ie the distributed transaction manager) ?

            2) If I wish to run a distributed transaction say using Spring hosted within JBoss can I use JBoss distributed transaction manager (I presume it has one) without resorting to EJB ?

            Does anyone know of any 'cookbook recipes' for setting up either of these in conjunction with Spring ?

            Thanks for advice so far - any help appreciated

            Comment

            Working...
            X