In my day to day job I’m a Java coder working on a MacBook Pro running OS X (Mountain Lion) and recently one thing started to really annoy me. While performing an Apache Maven build cycle occasionally an application pops up in my OS X dock and while browsing the web or composing an e-mail the focus is lost and moves to the just started application. In my case these applications are most of the time called Bootstrap or ForkedBooter.
I asked around a little if any of my fellow coders experienced this as well and it seems so, but nobody took the time to figure out what was going on. The answers are out there on the web, but you really need to know what to search for before finding a proper answer.
If you see the ForkedBooter application pop up in your dock this is most likely due to the maven-surefire-plugin which is being executed during the test phase of the Maven build lifecycle.
It’s actually quite easy to get rid of this application popping up in the OS X dock by telling Maven to run Java in headless mode. To do so I’ve added the following line to my .bash_profile file stored in my users home directory. In my case this is located in /Users/jreijn.
export MAVEN_OPTS="-Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=256m -Djava.awt.headless=true"
By adding the headless directive it will tell Maven and the plugins (which embrace the MAVEN_OPTS) to run Java in headless mode.
This should resolve the ForkedBooter popping up in the OS X dock.
The Bootstrap application showing up in the dock is actually quite specific and originates from starting up Apache Tomcat somewhere during the Maven build. In my specific case this was because at Hippo we use the cargo-maven2-plugin to fire up Apache Tomcat to run the CMS and site web application inside a Tomcat instance.
There are several ways of solving this. One of the possible options I found was to change Tomcats conf/catalina.properties file and add the following line at the end of the file.
When using a standalone Tomcat instance this way of solving is fine, but you could also add this to the catalina.sh or the startup.sh scripts.
Now in the scenario of using the Maven cargo plugin the container might be reinstalled on every build and this will overwrite your changes. There are two (or more) approaches again to solve this problem.
The first approach would be to add the catalina.properties file to your local project and copy it over when cargo installs the container.
The problem with this approach is that you will have a local copy inside your project which you have to recheck when upgrading the cargo plugin or the container instance or it might not work when switching to a different container then Tomcat.
The other more simple approach which will work across multiple containers is by adding a system property to the cargo plugin.
This way the system property is added to the Java run-time when starting up Tomcat from cargo and the Bootstrap application does not pop up anymore inside the OS X dock.
I hope this post will help those of you in search for the same answers and could not find it.