Announcement Announcement Module
No announcement yet.
Need advice regarding JTA Hib and Transactional File Access Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need advice regarding JTA Hib and Transactional File Access

    Hey everybody, my current situation is this: I'm using hibernate with springs HibernateTransactionManager on my proxied business service classes with TransactionProxyFactoryBean. I've now run into a situation where I am doing some file read/write/create/deletes in the same method as hibernate acesses, and what gets written into my db depends on the file operations. For example if a user wishes to replace a file in my app my method will load the row from hibernate to get the file name, delete the file, create a new file, save it, then save its name into my db on that row. Currently if an exception is thrown from the file accesses it will roll back the database transaction, however the files will be in a semi unknown state (did the delete fail? did the new write fail?). And similarly if it fails writing to the database the files are all in their new condition but the database is rolled back. So major problems.

    To attempt to solve this I just noticed the Commons Transaction project, and specifically within that, Transactional File Access I would like to integrate this into my methods where I have a single transaction working with hibernate and the File Resource Manager. However I can only see a couple ways of doing this:

    1-Extending the HibernateTransactionManager and shoehorning in the code to work with the Transactional File Package. This would be VERY ugly and may not even work since the transaction object passed around is specific to hibernate, and not meant to hold information for this new stuff.

    2-Migrating my setup to JTA and using a HibernateTransactionManager in conjunction with a new TransactionManager for this file tranasactional behavior.

    I have MANY questions on #2.. beginning with is there anything in spring that already does this? Darn didn't think so. So secondly I use Tomcat as my webserver, and I've read there is JOTM that can implement JTA.. has anyone sucessfully used that with spring and Tomcat 5.x? Also would I need to do any configuration changes to my current setup with hibernate to make it work under JTA? I'm using declarative transaction management right now pointing at specific methods to wrap transactions around, would that still work the same with JTA or do I have to move all that stuff into a JTA config somehow? Is it going to be really difficult and not worth the effort to write a transaction manager for commons transaction?

    I appreciate any help and advice given as this is new territory for this developer.


  • #2
    I am also facing this same issue as well for the project we are working on. So any solutions in this area would be of use to me as well. Mabye we can come up with a solution w/ the spring developers for this to contribute back to the community.


    • #3
      Spring Transactional File Access

      Same problem here...any hints in this direction



      • #4
        I can provide the hints:
        But haven't made much progress since making that public



        • #5

          Commons Transaction does not support XA transactions, afaik. You can use XADisk to perform the file operations inside the XA transaction. This same XA transaction can include other XA-enabled resources like database also.

          Hope that helps.

          Last edited by nitin_verma; Feb 12th, 2012, 03:38 AM.


          • #6
            thanks for the post...