ksnortum
ksnortum

Reputation: 3057

Building a war file that can be deployed by Maven Tomcat plugin

This is not technically a programming question, but a question about an error I get when deploying my war file from a Maven project.

The error I'm getting after I build my war file, run Tomcat7, and open a browser is:

HTTP Status 404 - /vaadin-test/

type Status report

message /vaadin-test/

description The requested resource (/vaadin-test/) is not available.

I am using Vaadin as my web app platform. I have a very simple project I'm trying to run for testing. I'm using tomcat7-maven-plugin and maven-war-plugin in my POM file. The war plugin configuration looks like this (I don't think I even need the filtering):

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>

            <configuration>
                <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
                <warName>vaadin-test</warName>

                <webResources>
                    <resource>
                        <directory>src/main/webapp/</directory>
                        <filtering>true</filtering>

                        <includes>
                            <include>**/*.xml</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

The web.xml looks like this:

<servlet>
    <servlet-name>myservlet</servlet-name>
    <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>

    <init-param>
        <param-name>application</param-name>
        <param-value>com.catalystitservices.vaadin.TestApp</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>myservlet</servlet-name>
    <url-pattern>/test-app</url-pattern>
</servlet-mapping>

Whether I try to run mvn tomcat7:run or deploy the created war file to an external Tomcat server (via the manager page) I get the same error. This leads me to think I'm not building the war file correctly. There are no error logs that I can find (but maybe I'm missing them).

Any ideas?

Upvotes: 2

Views: 2579

Answers (1)

anttix
anttix

Reputation: 7779

If you do not have <finalName> specified in your <build> block, Maven will create a war name in the following format:

vaadin-test-1.0.war

Where vaadin-test is the artifact name and 1.0 is the version string.

Therefore the url you have to refer to is /vaadin-test-1.0 not /vaadin-test

In addition your vaadin servlet is bound to a url /test-app so after you add the finalName tag , a complete URL should be something like: /vaadin-test/test-app

NB! Please note that 1.0 here is merely an example, please consult your own pom.xml for the real value

Upvotes: 5

Related Questions