xml - java.lang.ClassNotFoundException: com.springhibernatemvc.dao.PersonDAOImpl -
i having error in servlet-context.xml. saying can find below classes there exist in projecct folder.
<beans:bean id="persondao" class="com.springhibernatemvc.dao.persondaoimpl"> <beans:property name="sessionfactory" ref="hibernate4annotatedsessionfactory" /> </beans:bean> <beans:bean id="personservice" class="com.springbibernate.services.personserviceimpl"> <beans:property name="persondao" ref="persondao"></beans:property> </beans:bean>
it saying class not found
- class 'com.springbibernate.services.personserviceimpl'
my servlet-context file defined in web.xml file
<servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/appservlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
i have adding servlet-context.xml root folder of web app still error exists.
complete stacktrace
org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.web.servlet.mvc.method.annotation.requestmappinghandlermapping#0': invocation of init method failed; nested exception org.springframework.beans.factory.cannotloadbeanclassexception: cannot find class [com.springhibernatemvc.dao.persondaoimpl] bean name 'persondao' defined in servletcontext resource [/web-inf/spring/appservlet/servlet-context.xml]; nested exception java.lang.classnotfoundexception: com.springhibernatemvc.dao.persondaoimpl related cause: org.springframework.beans.factory.cannotloadbeanclassexception: cannot find class [com.springhibernatemvc.dao.persondaoimpl] bean name 'persondao' defined in servletcontext resource [/web-inf/spring/appservlet/servlet-context.xml]; nested exception java.lang.classnotfoundexception: com.springhibernatemvc.dao.persondaoimpl
what wrong?
from java docs
thrown when application tries load in class through string name using:
- the forname method in class class.
- the findsystemclass method in class classloader .
- the loadclass method in class classloader.
but no definition class specified name found.
the problem here not servlet-context.xml beans defined in there. make sure full cannonical class names correct , respective class files present under web-inf or library under .
from first high level seems defining bean class 'com.springbibernate.services.personserviceimpl'
where correct name appears 'com.springhibernate.services.personserviceimpl'
so xml content should :
<beans:bean id="persondao" class="com.springhibernatemvc.dao.persondaoimpl"> <beans:property name="sessionfactory" ref="hibernate4annotatedsessionfactory" /> </beans:bean> <beans:bean id="personservice" class="com.springhibernate.services.personserviceimpl"> <beans:property name="persondao" ref="persondao"></beans:property> </beans:bean>
Comments
Post a Comment