Announcement Announcement Module
No announcement yet.
Spring 3.1.1 java based configuration issue of [HTTP Status 404] Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3.1.1 java based configuration issue of [HTTP Status 404]

    I have been using the new feature of Spring 3.1.1 the "java based configuration".
    I have faced an issue while creating a small demo to test that new concept.

    When I deploy my "springway.war" over tomcat and request "http://localhost:8080/springway/" --> I got "HTTP Status 404"

    I am sure that I missing something but I couldn't figure it out .
    I have been looking at the "GreenHouse" example that is over Spring site but I still get the same issue.

    Here is my :

       package config;
        import java.util.List;
        import javax.inject.Inject;
        import org.springframework.context.annotation.Bean;
        import org.springframework.context.annotation.Configuration;
        import org.springframework.core.env.Environment;
        import org.springframework.http.converter.HttpMessageConverter;
        import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
        import org.springframework.validation.Validator;
        import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
        import org.springframework.web.multipart.MultipartResolver;
        import org.springframework.web.multipart.commons.CommonsMultipartResolver;
        import org.springframework.web.servlet.ViewResolver;
        import org.springframework.web.servlet.config.annotation.EnableWebMvc;
        import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
        import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
        import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
        import org.springframework.web.servlet.view.UrlBasedViewResolver;
        import org.springframework.web.servlet.view.tiles2.TilesConfigurer;
        import org.springframework.web.servlet.view.tiles2.TilesView;
        public class WebConfig extends WebMvcConfigurerAdapter {
            private Environment environment;
            public void addResourceHandlers(ResourceHandlerRegistry registry) {
            public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
                converters.add(new MappingJacksonHttpMessageConverter());
             * ViewResolver configuration required to work with Tiles2-based views.
            public ViewResolver viewResolver() {
                UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
                return viewResolver;
             * Configures Tiles at application startup.
            public TilesConfigurer tilesConfigurer() {
                TilesConfigurer configurer = new TilesConfigurer();
                configurer.setDefinitions(new String[]{
                return configurer;
            public MultipartResolver multipartResolver() {
                CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
                return multipartResolver;
    And the web.xml:

        <?xml version="1.0" encoding="UTF-8"?>
        <web-app version="2.5" xmlns=""
            <!-- Java-based annotation-driven Spring container definition -->
            <!-- Location of Java @Configuration classes that configure the components that makeup this application -->
            <!-- Specifies the default mode of this application, to be activated if no other profile (or mode) is specified -->
            <!-- Creates the Spring Container shared by all Servlets and Filters -->
                 <!-- Handles requests into the application -->
                    <!-- No explicit configuration file reference here: everything is configured in the root container for simplicity -->
    Last edited by Fatla; Mar 24th, 2012, 02:07 PM.

  • #2
    Judging by your configuration there is nothing to show so what should be shown? There eis no controller configuration there is no controller/component scanning detecting those. Next to that you use tiles but return a FreemarkerView...


    • #3
      I have noticed that over the "Green House" there is a class called App Controller that's called when the app starts up.
      I assume that is the one that's responsible to scan the controllers.
      However when I used this class,it's not called from my demo.
      You can see my demo attached.


      • #4
        I have fixed that freeMarker issue that you have noticed.


        • #5
          my main issue is how to configure/scan the controllers!!


          • #6
            I would take a look at the spring reference documentation.

            You need to use the following annotation at the top of your java config:


            • #7
              Thanks it works now.