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

  • SEARCH
  • Home
  • 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 8018737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:11:55+00:00 2026-06-04T21:11:55+00:00

I have configured hibernate & Spring without any errors and my project is deploying,

  • 0

I have configured hibernate & Spring without any errors and my project is deploying, however I’m try to load my Home.jsp via a controller “HomeController” but I’m getting “Error :404 Resource not found…”:


I have tried 3 different approaches:

Approach Number 1 (Not my ideal approach).

a) Define a index.htm in welcome list (web.xml)

b) Map HomeController to “/index.htm” via annotations using @Controller @RequestMethod

c) HomeController returns view “Home” (WEB-INF/views/Home.jsp)


Common project structure used for all 3 approaches:

enter image description here


Web.xml:

<web-app metadata-complete="true" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>yourmarketnet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>yourmarketnet</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout> 
            30 
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.htm</welcome-file>
    </welcome-file-list>
</web-app>

Yourmarketnet-spring.xml snippet:

  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"     
        p:prefix="/WEB-INF/views/" p:suffix=".jsp" p:viewClass="org.springframework.web.servlet.view.JstlView" />

applicationContext.xml:

<!-- Activates various annotations to be detected in bean classes --> 
    <context:annotation-config />
    <!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.   For example @Controller and @Service. Make sure to set the correct base-package--> 
    <context:component-scan base-package="com.yourmarketnet.controller" />    
    <!-- Configures the annotation-driven Spring MVC Controller programming model.  Note that, with Spring 3.0, this tag works in Servlet MVC only!  --> 
    <mvc:annotation-driven/>
    <!-- mapping of static resources-->
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <import resource="hibernate-context.xml" />

HomeController Class:

package com.yourmarketnet.controller;
@Controller  
@RequestMapping("/index.htm") 
public class HomeController {  
    public String requestHandler()
    { 
        return "Home"; 
    } 
}   

Result of Running application :

Http Status 404

The requested resource () is not available.


Approach Number 2, (Not my ideal approach)

a) Create redirect.jsp , and define welcome list (web.xml)

b) Map HomeController to “ /HomeController” via annotations using @Controller @RequestMethod

c) Have redirect.jsp “<% response.sendRedirect(“/HomeController”);%>” to my HomeController

d) HomeController returns view “Home” (WEB-INF/views/Home.jsp)

Web.xml:

<web-app metadata-complete="true" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>yourmarketnet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>yourmarketnet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout> 
            30 
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
</web-app>

Yourmarketnet-spring.xml snippet:

 <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"     
        p:prefix="/WEB-INF/views/" p:suffix=".jsp" p:viewClass="org.springframework.web.servlet.view.JstlView" />
 </beans>

applicationContext.xml snippet:

<!-- Activates various annotations to be detected in bean classes --> 
    <context:annotation-config />
    <!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.   For example @Controller and @Service. Make sure to set the correct base-package--> 
    <context:component-scan base-package="com.yourmarketnet.controller" />    
    <!-- Configures the annotation-driven Spring MVC Controller programming model.  Note that, with Spring 3.0, this tag works in Servlet MVC only!  --> 
    <mvc:annotation-driven/>
    <!-- mapping of static resources-->
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <import resource="hibernate-context.xml" />

HomeController Class:

package com.yourmarketnet.controller;
@Controller  
@RequestMapping("/HomeController") 
public class HomeController {  
    public String requestHandler()
    { 
        return "Home"; 
    } 
}

Result of Running application :

Http Status 404 /HomeController

The requested resource (/HomeController) is not available.


Approach Number 3, (If any off the above works its fine, however this is what I really want)

a) Remove all welcome file tags from web.xml

b) MapDispatcher to “/”

c) Map HomeController to “/HomeController” via annotations using @Controller @RequestMethod’

d) HomeController returns view “Home” (WEB-INF/views/Home.jsp)

Web.xml:

<web-app metadata-complete="true" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>yourmarketnet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>yourmarketnet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout> 
            30 
        </session-timeout>
    </session-config>
</web-app>

**Yourmarketnet-spring.xml snippet: **

   <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"     
        p:prefix="/WEB-INF/views/" p:suffix=".jsp" p:viewClass="org.springframework.web.servlet.view.JstlView" />

applicationContext.xml snippet:

<!-- Activates various annotations to be detected in bean classes --> 
    <context:annotation-config />
    <!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.   For example @Controller and @Service. Make sure to set the correct base-package--> 
    <context:component-scan base-package="com.yourmarketnet.controller" />    
    <!-- Configures the annotation-driven Spring MVC Controller programming model.  Note that, with Spring 3.0, this tag works in Servlet MVC only!  --> 
    <mvc:annotation-driven/>
    <!-- mapping of static resources-->
    <mvc:resources mapping="/resources/**" location="/resources/" />
    <import resource="hibernate-context.xml" />

HomeController Class:

package com.yourmarketnet.controller;
@Controller  
@RequestMapping("/") 
public class HomeController {

    public String requestHandler()
    { 
        return "Home"; 
    } 
}   

Apache Server log:

WARNING: No mapping found for HTTP request with URI [/yourmarketnet/] in DispatcherServlet with name ‘yourmarketnet’

Result of Running application :

Http Status 404

The requested resource () is not available.

Please provide me with the correct code/tags in order to server my Home.jsp from HomeController without 404 Error, Thank you.

  • 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-04T21:11:56+00:00Added an answer on June 4, 2026 at 9:11 pm

    I am talking about the third approach from your question.

    In your web.xml change the request mapping to / instead of *.htm.
    Everything else if just perfect as I can see here. So this should work for you.

    Hope this helps you.

    Cheers.

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

Sidebar

Related Questions

I have a Spring/JPA application with Hibernate as the JPA provider. I've configured a
I have Hibernate Transaction manager configured inside Spring MVC controller. <bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource destroy-method=close>
I am using spring/hibernate. i have configured 5 datasources in applicationContext.xml file. All datasources
Hello I have strange problem. I configured spring + hibernate. I`m using annotation configuration
I was trying to configure spring 3.1 and hibernate. I have written a simple
I have configured spring security with a ldap server (but continue reading, it's not
I have configured my account on GitHub to host my Xcode project. I followed
I have configured a project with scm that downloads a project and apply some
I'm getting a LazyInitializationException in my Spring Application. I have the OpenEntityManagerInViewFilter configured so
I have a c# library project, that i configured using nhibernate, and I like

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.