Tomcat 7 deploying issue

I am making a example from the book spring recipes and and i cant seem the deploy the example into tomcat. I am trying to open the messageList.htm page but i always get the HTTP Status 404 error.

Someone can help me?

thx in advance

This is the code:

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<: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 ">
    <:context-param>
        <:param-name>contextConfigLocation</:param-name>
        <:param-value>/WEB-INF/board-service.xml</:param-value>
    </:context-param>

    <:listener>
    <:listener-class>org.springframework.web.context.ContextLoaderListener</:listener-class>
    </:listener>

    <:servlet>
    <:servlet-name>Chapter5Security</:servlet-name>
    <:servlet-class>org.springframework.web.servlet.DispatcherServlet</:servlet-class>
    </:servlet>

    <:servlet-mapping>
    <:servlet-name>Chapter5Security</:servlet-name>
    <:url-pattern>/*</:url-pattern>
    </:servlet-mapping>
</:web-app>

board-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<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-3.1.xsd">
    <bean id="messageBoardService" class="service.MessageBoardServiceImpl" />

</beans>

board-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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="web"></context:component-scan>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>

MessageListController

@Controller
@RequestMapping("/messageList*")
public class MessageListController {

    private MessageBoardService messageBoardService;

    @Autowired
    public MessageListController(MessageBoardService messageBoardService)
    {
        this.messageBoardService=messageBoardService;
    }

    @RequestMapping(method= RequestMethod.GET)
    public String generateList(Model model)
    {
        List<Message>messages=java.util.Collections.emptyList();
        messages=messageBoardService.ListMessages();
        model.addAttribute("messages",messages);
        return "messageList";
    }
}

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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>be.glennvdv.BookSpring</groupId>
  <artifactId>Chapter5Security</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Chapter5Security Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
          <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>
            <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>
            <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>

        <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
        <version>3.1.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
            <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-ldap</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
            <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
            <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
            <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
            <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-acl</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>

  </dependencies>
    <build>
    <finalName>Chapter5Security</finalName>
    <plugins>
        <plugin>

            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <configuration>
            <server>myserver</server>

            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

messageList.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<html>
<head>
<title>Message List</title>
</head>

<body>

<c:forEach items="${messages}" var="message">
<table>
  <tr>
    <td>Author</td>
    <td>${message.author}</td>
  </tr>
  <tr>
    <td>Title</td>
    <td>${message.title}</td>
  </tr>
  <tr>
    <td>Body</td>
    <td>${message.body}</td>
  </tr>
  <tr>
    <td colspan="2">
      <a href="messageDelete?messageId=${message.id}">Delete</a>
    </td>
  </tr>
</table>
<hr />
</c:forEach>
<a href="messagePost">Post</a>
</body>
</html>

Answers


HTTP 404 means that the URL you're giving in the browser didn't map to the page that you hoped it would.

If you deploy your app as a WAR file named foo.war to Tomcat, I'd expect the URL to look like this:

http://localhost:8080/foo/messageList.html

Play with that syntax until you get it right.

If Maven is a black box to you, I'd recommend creating and deploying a WAR file by hand until you figure this out.


Got it working. 1: web.xml was not well formed 2: Needet jstldependency


Need Your Help

OMR/OCR on android

android sdk ocr

I am going to build of a counting of vote program with optical MC sheet in android platform