Search code examples
mavenseleniumjbehavemaven-tomcat-pluginjbehave-plugin

Embedded tomcat won't let my selenium/jbehave stories run


I am trying for the embedded tomcat to start before the integration tests (mine use Selenium + JBehave) and stop just afterwards.

Here is how I tried to configure maven:

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
            <executions>
                <execution>
                    <id>start-tomcat</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
                <execution>
                    <id>stop-tomcat</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

However, Tomcat starts ok when I run mvn integration-test and it seems it won't let my stories run...

Can anyone help?


Solution

  • I think I found the solution. It works with the following configuration:

    <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.0</version>
                    <configuration>
                        <fork>true</fork>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-tomcat</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-tomcat</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    

    Notice the added configuration element which tells tomcat to fork.