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 8079265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:03:12+00:00 2026-06-05T16:03:12+00:00

I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working

  • 0

I am having problem using mvc:resources in spring 3.1 configuration.

Initially i was working on the project that integrates spring 3.0, JPA, on tomcat 6.
On tomcat 6 server, i used the following servlet-mapping in web.xml to access static contents(css,js and png etc) from my application.

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/static/*</url-pattern>
</servlet-mapping>

I am not sure if it is best practice but it worked fine on tomcat6 environment. It doesnt work on tomcat 7. So i switched to spring 3.1 to use the mvc:resources element in applicationContext. I changed xml namespaces for 3.1 and added the two lines in applicationContext.xml.

<mvc:annotation-driven/>
<mvc:resources location="/resources/" mapping="/static/**"/>

The whole application worked very well before I added the above two lines of configuration. But now all annotated controllers are not detected by the framework. I dont have index.jsp or any welcome files in application root and I mapped root requests “/” to annotated RootController.java. So the appliation home page is not even loaded.

When i check around the net in search of the solutions, i found out that mvc:annotation-driven replaces some default bean configuration that i think is implicitly defined by the framework. I found some solutions that works for some people in this forum which is to explicitly define some bean configuration by myself.
I tried adding the following two lines

<bean class ="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> 
<bean class ="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

But unfortunately that doesn’t solve my problem. I am not sure if it is the real problem that i am facing now ,so here is my applicationContext.xml for you to check my current configuration.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

    <context:component-scan base-package="com.yewintko.uog.emailcampaignmanager">
        <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
    </context:component-scan>

    <tx:annotation-driven/>
    <mvc:annotation-driven/>

    <mvc:resources location="/resources/" mapping="/static/**"/>
<bean class = "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" /> 
<bean class = "org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>   

<context:property-placeholder location="classpath:database.properties"/>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${database.driver}"/>
        <property name="url" value="${database.url}"/>
        <property name="username" value="${database.username}"/>
        <property name="password" value="${database.password}"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

    <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="EmailCampaignManager"/>
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="databasePlatform" value="${database.platform}"/>
                <property name="showSql" value="${database.showSql}"/>
                <property name="generateDdl" value="${database.generateDdl}"/>
            </bean>
        </property>
        <property name="jpaProperties">
            <props>
                <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
            </props>
        </property>
    </bean>
</beans>

I am very new to spring and have no idea which configuration is missing in my applicationContext. Please someone help me if you have a little free time. If you need more information please let me know.

regards
Yewint

  • 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-05T16:03:14+00:00Added an answer on June 5, 2026 at 4:03 pm

    Your annotated controllers are not getting scanned by Spring is because of following line in your applicationContext.xml file.

    <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
    

    Please remove that line and it will resolve your issue. 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've been having a problem regarding using AJAX with Spring MVC. I have a
I'm using MVC 2 for a project and I'm having a problem with a
I am working on a mvc project, and having problem with json. i have
I am using spring MVC and having a problem in jsessionid, what I found
I'm using ASP.NET MVC + NHibernate + Fluent NHibernate and having a problem with
I'm using the Telerik Extensions for ASP.NET MVC 3 and I'm having a problem
I'm having a problem with JQGrid using ASP.NET MVC. I'm trying to follow this
I'm using ASP.NET MVC 3 to build an application, but i'm having a problem
I'm working on a reporting web application using JasperReport and Spring MVC 3 to
I am having a problem rendering my view in the layout page using mvc

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.