• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Spring Security: Unable to autowired sessionFactory in the UsersDAOImpl

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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?
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!