500 error -- CannotLoadBeanClassException

Viewed 93

I am getting a 500 error from my Spring web application. The mentioned files are correctly named and in the correct packages. Here is the error message.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.dao.CommentDAO] for bean with name 'commentDAO' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.dao.CommentDAO
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.dao.CommentDAO] for bean with name 'commentDAO' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.dao.CommentDAO
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.controller.PagesController] for bean with name 'pagesController' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.controller.PagesController
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.controller.CommentController] for bean with name 'commentController' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.controller.CommentController

Here is the relevant portion of ghs1986-servlet.xml.

<bean id="commentDAO" class="com.dao.CommentDAO">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="pagesController" class="com.controller.PagesController" />

    <bean id="commentController" class="com.controller.CommentController">
        <property name="commentDAO" ref="commentDAO" />
    </bean>
1 Answers

Problem solved. I needed the @Component annotation on CommentDAO.

Related