• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring/Hibernate/Jboss/JTA/getCurrentSession()/createQuery is not valid without active transaction

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on JTA with Hibernate getCurrentSession(), I am using spring--> AOP transactions.

Dao class where the exception is ocurring.


I am injecting sessionFactory into Dao* implementations. When I do Code inspection on sessionFactory in AbstractCRUDDao, transactionManager is null

What are the configuration/code changes that I need to do to get this to work? Following is the error that I am getting



Following is the applicationContext.xml

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Santosh,

This is from my appContext file which works. Thought it might help you out




And then my RoleDao class extends org.springframework.orm.hibernate3.support.HibernateDaoSupport;



Other than that my context is pretty much the same as yours.


Although, now that I look at it I dont do things like



I get the session from the HibernateDaoSupport class. Take a look at the API
http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/orm/hibernate/support/HibernateDaoSupport.html


example:



Hope that helps


 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seamus, Thanks for your reply. I got past the above error with following configuration in my applicationContext.xml


Now I am getting following error




I did some google and made the following changes to configurations but still it does not work as of now.




 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seamus, Is your DAO handling transactions at method level using HibernateTemplate? Can you please post your DAO code if you can?
 
Seamus Minogue
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Santosh,

Actually transaction handling is being done at the service level. The reason being:

My service may call multiple DAO's and if any of them throw and error I want to rollback the transaction. Here is my DAO:




And here is the snippet from my applicationContext which does the transaction stuff:



Hope that helps.
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following configuration worked for me(got some help from Spring forum). With Spring JTA/Jboss5.0/Hibernate3.2

Issue in my configuration was AOP decleration and I had to comment out this piece of code


Configuration that worked for me




With this
I was getting following exception
 
Fire me boy! Cool, soothing, shameless self promotion:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic