aspose file tools*
The moose likes Spring and the fly likes org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [LoginHibernateDao Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [LoginHibernateDao" Watch "org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [LoginHibernateDao" New topic
Author

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

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
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

Joined: May 31, 2013
Posts: 47
Do you have Your Login Dao interface and User Model Object present in the class library?
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

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.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Balaji Vankadaru
Ranch Hand

Joined: May 31, 2013
Posts: 47
Oh yeah you need to give complete details of your class along with package name.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
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

Joined: Aug 11, 2011
Posts: 440

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

Joined: Jul 07, 2012
Posts: 644
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

Joined: Jul 07, 2012
Posts: 644
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

Joined: Jul 07, 2012
Posts: 644
Thanks all.Its working now.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [LoginHibernateDao