Thursday, November 20, 2014

Setting JAVA_HOME for Bitnami Apache Tomcat stack as a Windows Service


You can't set it to a different JAVA_HOME, you'll have to set your JAVA_HOME to the Bitnami JDK if you want a consistent JDK.

Setting the Bitnami Tomcat JAVA_HOME on Windows

The Problem

The Bitnami Tomcat stack packages it's own JDK and uses it over the existing JAVA_HOME directory.  This means that if you want a consistent JDK between your unit tests and in-container tests (and you do) you either need to set your usual JAVA_HOME to the Tomcat version or get Tomcat to use the system JAVA_HOME.

The Background

This tutorial is about the latter, as I have already installed the Java Cryptography Extension (JCE) unlimited strength jurisdiction policy files into the system JAVA_HOME (as per a blog post on Suhorish!) and didn't want to do it again.

The Research

After going through several stackoverflow questions and a Bitnami community post I found that they all suggested changing the various Windows BAT files in /bin and /scripts.  This did not work.

The Experiments

Digging into the Windows Service properties I found that the tomcat7.exe is called directly, therefore bypassing all of these scripts.

I eventually decided to use Junction Link Magic to create a hard link from Bitnami/tomcatstack/java to my actual JAVA_HOME... and that didn't work.  The Tomcat service will fail with Application Error 1 and an event error of:
The tomcatstackTomcat service terminated with the following service-specific error: 
Incorrect function.

So I tried to bypass the service by calling the scripts directly, also to no avail.

The Conclusion

This led me to the tl;dr at the start of this article.  I hate admitting defeat.

No comments:

Post a Comment