I am working on a Spring 4.0.1 mvc application and **my browser cannot render any resource** of my app.

I am **configuring** my application **via annotations**, rather than xml files. This is why I am asking this question and not reusing any already given answer. Searching for my problem only led me to people who don't use annotations. I did follow this [tutorial](http://javahash.com/spring-4-mvc-hello-world-tutorial-full-example/). Maven is my build tool and Eclipse kepler my IDE.

Can anyone please help me? I would appreciate any tips and resources.

### Here is my system setup:

* I try to reach the webapp on `http://localhost:8080/Spring4MVCHelloWorld/hello`.
* The tomcat catalina log does not show any error.
* `mvn clean package` are my executed maven goals.
* Here you can find the **project on GitHub**: <https://github.com/Husterknupp/spring-octo-lana>

In This is the tomcat error report:

> 
> ### HTTP Status 404 - /Spring4MVCHelloWorld/
> 
> 
> type Status report  
> 
>  message /Spring4MVCHelloWorld/  
> 
>  description The requested resource is not available.
> 
> 
> 

This is my `pom.xml`:

```
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.bschandera.jeetutorials</groupId>
    <artifactId>Spring4MVCHelloWorld</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Spring4MVCHelloWorld Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <spring.version>4.0.1.RELEASE</spring.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <!-- Spring dependencies START -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- Spring dependencies END -->

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
                    <scope>provided</scope> <!-- provided because servlet api jar file must not be embedded inside the 
            webapp since, obviously, the container already has these classes in its classpath: 
            it implements the interfaces contained in this jar -->
        </dependency>

    </dependencies>

    <build>
        <finalName>Spring4MVCHelloWorld</finalName>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

```

Under `src/main/java` there are these three classes:

1. Config.java:

```
package de.bschandera.jeetutorials.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.UrlBasedViewResolver;

@Configuration
// Marks this class as configuration
// Specifies which package to scan
@ComponentScan("de.bschandera.jeetutorials.config")
// Enables Spring's annotations
@EnableWebMvc
public class Config {
    @Bean
    public UrlBasedViewResolver setupViewResolver() {
    UrlBasedViewResolver resolver = new UrlBasedViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".jsp");
    resolver.setViewClass(JstlView.class);
    return resolver;
    }
}

```
2. HelloWorldController.java:

```
package de.bschandera.jeetutorials.config;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class HelloWorldController {

    @RequestMapping("/hello")
    public String hello(@RequestParam(value = "name", required = false, defaultValue = "World") String name, Model model) {
    model.addAttribute("name", name);
    return "helloworld";
    }

}

```
3. WebInitializer.java:

```
package de.bschandera.jeetutorials.config;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

public class WebInitializer implements WebApplicationInitializer {

    public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Config.class);

    ctx.setServletContext(servletContext);

    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);

    }

}

```

Under `src/main/webapp/WEB-INF/views` there is `helloworld.jsp`:

```
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Spring4 MVC -HelloWorld</title>
  </head>
  <body>
    <h1>Hello : ${name}</h1>
  </body>
</html>

```

Under `src/main/webapp/WEB-INF` there is the `index.jsp`

```
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Spring4 MVC -HelloWorld INDEX</title>
  </head>
  <body>
    <h1>Index page - welcome!</h1>
  </body>
</html>

```

---

After having the first three answers not solving the problem, I would imagine that the problem has to do with any **tomcat configuration** or anything else but the code itself. But I dont know where to look for asides the suggested solutions.