This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Spring Security: Unable to autowired sessionFactory in the UsersDAOImpl

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody,

I'm trying to map the users to the Spring Security users. However my UsersDAOImpl class cannot be autowired sessionFactory property.

My spring-security.xml



I am scanning all my components by this tag:



This is my springmvc-servlet.xml



And this is my CustomUserDetailsService class



My UsersDao class

My UsersDAOImpl is:


Web.xml



And I get this error:




Before adding security part, everything was perfectly working. I do not understand what happened.
Thanks for everything
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are declaring bean of type org.springframework.orm.hibernate4.LocalSessionFactoryBean in your springmvc-servlet.xml file and trying to autowire org.hibernate.SessionFactory in UsersDAOImpl class and also you are using both autowired and setter based dependency injection for the same property(sessionFactory), I can't understand why.
 
Burak Keceli
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see your point about autowired and setter dependency injection. I deleted these two beans.



My new springmvc-servlet.xml is this:



However error did not change.




But I did not understand "org.springframework.orm.hibernate4.LocalSessionFactoryBean" and "org.hibernate.SessionFactory" issue. What should I do? SessionFactory is only importted by org.hibernate.SessionFactory
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you try setter based injection, instead of autowired for the sessionFactory?
Also, are you sure you have hibernate4 jars and no hibernate3 jars are present?
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersController':


I see exception message, but no where i can see usersController bean definition, how have you defined it?
 
reply
    Bookmark Topic Watch Topic
  • New Topic