Failure To Shutdown Embedded Tomcat Instance In Bamboo

I am attempting to run integration tests on an embedded tomcat instance in a multi-module maven project. I am using the tomcat7-maven-plugin configured as follows:

<plugin>
					<groupId>org.apache.tomcat.maven</groupId>
					<artifactId>tomcat7-maven-plugin</artifactId>
					<version>2.2</version>
					<configuration>
						<server>my-tomcat</server>
						<path>/svc</path>
						<url>http://localhost:8080/manager/text</url>
					</configuration>
					<dependencies>
						<dependency>
							<groupId>com.oracle</groupId>
							<artifactId>ojdbc6</artifactId>
							<version>11.2.0</version>
							<scope>runtime</scope>
						</dependency>
						<dependency>
							<groupId>com.cenqua.clover</groupId>
							<artifactId>clover</artifactId>
							<version>3.2.0</version>
							<scope>runtime</scope>
						</dependency>
					</dependencies>
					<executions>
						<execution>
							<id>start-tomcat</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>run-war-only</goal>
							</goals>
							<configuration>
								<fork>true</fork>
							</configuration>
						</execution>
						<execution>
							<id>stop-tomcat</id>
							<phase>post-integration-test</phase>
							<goals>
								<goal>shutdown</goal>
							</goals>
						</execution>
					</executions>
				</plugin>

But it appears that the server does not shutdown. It will either fail on the next clean or if I set my context's antiResourceLocking to true I can see that the next time run-war-only is called I get a binding error due to the port already being in use by the previous orphaned tomcat process. Everything runs fine outside of bamboo. What do I have to configure to make this work as it should? I am using bamboo version 5.2.2 build 4010. Thanks.

2 answers

When in doubt script it. If you can shut it down from the command line you can put it in a script to stop it that way. Wouldn't matter if you did it at the end of the build or as your first task in the next build.

Thanks for your reply Gretchen. The problem here is that it is an embedded instance, and I don't think a command line function will work. The shutdown method here is so far the only way I know of to shut down the embedded tomcat server. Is there another way? I haven't found anything.

I too saw the same issue. The only way around this I found was to start tomcat on different ports. My problem was specifically related to clover since clover ended up running the tests twice and the second time the bind on the default port 8080 failed. I worked around this by using a plugin to allocate random ports: http://mojo.codehaus.org/build-helper-maven-plugin/reserve-network-port-mojo.htmland using those ports in the tomcat maven plugin.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 11 hours ago in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

91 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you