0
votes

I am new in spring I am doing spring annotation example in eclipse luna same example working in myeclipse but not working in eclipse

getting this error can any one help me

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vcs.service.StudentService com.vcs.controller.StudentController.studentService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vcs.dao.StudentDao com.vcs.service.StudentServiceImpl.studentDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentdaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.vcs.dao.StudentdaoImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/DispatcherServlet-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)

2
If you read the error carefully, you'll see that you're missing a jar that contains the class org/hibernate/context/CurrentSessionContextAugusto

2 Answers

0
votes

Looking at the last error 'java.lang.NoClassDefFoundError' it looks as if you were missing a hibernate dependency (hibernate-core) that contains CurrentSessionContext.

0
votes

You are getting a NoClassDefFoundError exception for org.hibernate.context.CurrentSessionContext.

My guess is that under your eclipse setup, the required dependencies are not inside your class path.

Check the lib folder inside you war archive for your eclipse build. I am assuming it's a WAR archive from the presence of WEB-INF.

Can I also suggest you format your code in a code block to make for easier reading