Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [LoginHibernateDao

 
Monica Shiralkar
Ranch Hand
Posts: 855
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting below error message while attempting spring IOC:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [LoginHibernateDaoImpl] for bean with name 'loginHibernateDaoImpl' defined in class path resource [ApplicationContext.xml]; nested exception is java.lang.ClassNotFoundException: LoginHibernateDaoImpl
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:897)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:566)



LoginHibernteDaoImpl.java



Application Context.xml



LoginAction.java


thanks
 
Balaji Vankadaru
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have Your Login Dao interface and User Model Object present in the class library?
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a simple ClassNotFoundException , meaning your problem lies in just defining proper classpaths to the classes. Try to give fully qualified class names in the bean declaration in the applicationContext.xml.
 
Balaji Vankadaru
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah you need to give complete details of your class along with package name.
 
Monica Shiralkar
Ranch Hand
Posts: 855
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.I got rid of that error.However now I am facing another issue. The dao which should be set by the Spring IOC is coming null. Here is my entire code:

ApplicationContext.xml


LoginDao.java




In the above dao is comming null.






I am doing some small mistake because of which dao is getting set as null.

thanks
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be multiple possibilities for the cause of the null value returned from the DAO. The primary and fore-most reason would be that the query returned no record at all that matched your criteria of the username and password which you provided.
So I want you to check the following things for me

1. Make sure an entry exists in your DB for the userName and password that you are providing.
2. Check that the LoginAction class is receiving the correct values in the userName and password fields., just print them in the class to make sure that the values are there and correct.
3. Next , debug the DAOImpl class to make sure that the Query is returning any tuple at all .


Do post back for any further queries.
 
Monica Shiralkar
Ranch Hand
Posts: 855
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks but what the query returns has no effect on the issue.

I am talking of stage lot before the query returns.

The dao variable should be populated with a value: object of type LoginHibernateDaoImpl.Thats how spring IOC should work.

What I am trying to achieve is the functionality This line of code I should be able to do with spring IOC (without doing this tight coupling)

Hence dao should be populated with object of type LoginHibernateDaoImpl(). but for some reason spring IOC is not working and dao is null.


thanks
 
Monica Shiralkar
Ranch Hand
Posts: 855
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried drilled down to the problem area and it is the below code which is having some mistake:


before this I have created a field with setter method:


and my ApplicationContext.xml is as:



In the above code where I am going wrong that the value of dao is coming null? Please advice.Thanks.
 
Monica Shiralkar
Ranch Hand
Posts: 855
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all.Its working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic