Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8874783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:48:38+00:00 2026-06-14T18:48:38+00:00

I had created the simple spring MVC controller, when i tried to execute i

  • 0

I had created the simple spring MVC controller, when i tried to execute i am getting the error.

Error Message:

org.springframework.beans.factory.CannotLoadBeanCl assException: Cannot find class [SpringApp.web.java.HelloController] for bean with name ‘Redirect.jsp’ defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: SpringApp.web.java.HelloController

This is my application structure.

SpringApp

----Web Pages   
    ----META-INF    
    ----WEB-INF     
        ----springapp-servlet.xml
        ----web.xml
    ----Redirect.jsp    
    ----index1.jsp  
----Source Packages         
    ----java    
        ----HelloController.java




web.xml
--------

        <?xml version="1.0" encoding="UTF-8"?>
         <!--
    To change this template, choose Tools | Templates
    and open the template in the editor.
    -->

     <web-app version="2.4"
             xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

      <servlet>
        <servlet-name>springapp</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
        <servlet-name>springapp</servlet-name>
        <url-pattern>*.htm</url-pattern>
      </servlet-mapping>


      <welcome-file-list>
        <welcome-file>
          index1.jsp
        </welcome-file>
      </welcome-file-list>

    </web-app>

springapp-servlet.xml
----------------------


    <?xml version="1.0" encoding="UTF-8"?>
    <!--

    1. This file will be used up by the DispatcherServlet and which contains the bean         definition
    2. The file will be picked up by the specification in the WEB-INF/web.xml using         <servlet>spring</servlet>
    3. hello controller is responsible for handling the request for the particular page     of     the website and known
    as the page controller.
-->

    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

      <!-- the application context definition for the springapp DispatcherServlet -->

      <bean name="Redirect.jsp" class="SpringApp.web.java.HelloController"/>

    </beans>

index1.jsp
---------

        <%--
        Document   : index
        Created on : Nov 23, 2012, 11:55:53 AM
        Author     : gopc
    --%>

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1>Hello World!</h1>
        </body>
    </html>

Redirect.jsp
------------


<%--
    Document   : index
    Created on : Nov 23, 2012, 11:55:53 AM
    Author     : gopc
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Hello Controller redirect</title>
    </head>
    <body>
        <h1>This is redirect from the HelloController!</h1>
    </body>
</html>

HelloController.java
-------------------
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package java;
    /**
     *
     * @author gopc
    */



    import org.springframework.web.servlet.mvc.Controller;
    import org.springframework.web.servlet.ModelAndView;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;

    import java.io.IOException;

    public class HelloController implements Controller {

    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        logger.info("Returning hello view");
        System.out.println("hi this handlerequest");

        return new ModelAndView("Redirect.jsp");
        }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:48:39+00:00Added an answer on June 14, 2026 at 6:48 pm

    You say:

    <bean name="Redirect.jsp" class="SpringApp.web.java.HelloController"/>
    

    This means Spring is expecting to find your controller in the package SpringApp.web.java. You’ve put it in the package java.

    Change the package statement in your controller to be SpringApp.web.java, and move the source file to the appropriate directory SpringApp/web/java.

    Note also that the package java is reserved for the Java platform, so you shouldn’t be using it anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before Spring Security/MVC, I had a simple relatively insecure userobject stored in my sessions
I created a simple test page on my website www.xaisoft.com and it had no
I was iterating through a table I had created and getting the first cell
I have a very simple user model. When I first created it, it had
I created a small and simple webapp using Spring Security and SpringMVC and I'm
Hi I'm building a very simple search system using ASP.NET MVC. I had it
I've just started learning C# and had created this simple configuration file generator for
I had created one div window which is draggable,and created one child div (with
I had created the following view, SELECT currency_cd, SUM(comprate) AS salary, employee_code, (SELECT SUM(c.comprate)
I had created a Lib Project with a class inherits ServiceBase but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.