Results 1 to 6 of 6

Thread: Distributed transaction & jndi data sources

  1. #1
    Join Date
    Oct 2004
    Posts
    3

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    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
    Chris Harris
    Carlisle, UK

  3. #3
    Join Date
    Oct 2004
    Posts
    3

    Default

    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:

  4. #4
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    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

  5. #5
    Join Date
    Oct 2004
    Posts
    3

    Default

    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

  6. #6
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    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.




    Quote 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

Similar Threads

  1. Replies: 3
    Last Post: Dec 27th, 2009, 10:11 PM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. Replies: 1
    Last Post: Jan 6th, 2005, 11:07 PM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Transaction pb Hibernate/MySQL
    By syluser in forum Data
    Replies: 2
    Last Post: Aug 28th, 2004, 02:40 PM

Posting Permissions

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