This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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?
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!