Search code examples
jakarta-eemaven-2tomcat7maven-tomcat-plugin

maven-t7-plugin and blank pages


i want to run tomcat7 with maven 2 so i tried the maven-t7-plugin with following configuration:

<plugin>
                <groupId>com.googlecode.t7mp</groupId>
                <artifactId>maven-t7-plugin</artifactId>
                <version>0.9.6</version>
                <configuration>
                     <tomcatHttpPort>8081</tomcatHttpPort>
                     <tomcatShutdownPort>8008</tomcatShutdownPort>
                     <tomcatVersion>7.0.22</tomcatVersion>                                     
                </configuration>
            </plugin> 

but when trying to run the application using the command mvn t7:run

i can see that server started correctly with no problems:

Jan 4, 2012 12:50:22 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8081"]
Jan 4, 2012 12:50:22 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1044 ms
Jan 4, 2012 12:50:22 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 4, 2012 12:50:22 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.22
Jan 4, 2012 12:50:22 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8081"]
Jan 4, 2012 12:50:22 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 62 ms

but when trying to access any application page, all what i get is blank pages am i missing any thing any the configuration, or there's another problem ?


Solution

  • The t7mp plugin by default uses the file name of the generated war as the context root. Accesses to all other paths result in a blank page since the default error pages are not deployed. The file name and context path is ${artifactId}-${version} by default, you can change it by setting the finalName element in the build section of your pom.

    <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">
        ...
        <build>
            <finalName>contextRoot</finalName>
            ...
        </build>
    </project>
    

    You application would now be available at http://localhost:8081/contextRoot/ instead of for example http://localhost:8081/application-1.0-SNAPSHOT/.