Thursday, November 20, 2014

Setting JAVA_HOME for Bitnami Apache Tomcat stack as a Windows Service

tl;dr 

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.

Thursday, October 2, 2014

Make Ubuntu 14.04 Look Like Windows with Gnome

After setting up dual-booting with Windows 8 and Ubuntu one of the first things that I did was to have my Windows habits and my Ubuntu habits converge to make things (much) easier.  I decided to make Ubuntu look more like Windows.

There are already several posts about having Ubuntu look like Windows, however they have left out that in the default Unity desktop it is impossible to have your menu buttons (close, minimize, maximize) on the right hand side a la Windows (Unity Tweak Tool bug report).  This leads to needing to use an alternate desktop (like Gnome with the Gnome Tweak Tool) to achieve this effect.  It was pretty easy to switch.

Tuesday, September 23, 2014

Dual Booting Ubuntu 14.04 and Windows 8

Although there have been many, many posts, questions (Ubuntu Forums, Ask Ubuntu)and tutorials (Ubuntu.com) on this subject the solution is still elusive and complex.  Also some background information is needed before delving into the black art of modern boot loaders.  Also note that this article is focusing on having Windows as the primary boot loader and having it delegate to GRUB2 to boot Ubuntu.  This is the focus as Windows 8 will rewrite it's boot loader if it isn't the first OS to boot, wiping out GRUB boot info entirely.

Safety First

On the Ubuntu.com tutorial above it details backing up your entire system and creating recovery disks in case something goes wrong.  It would be a shame to have to reinstall your entire TWO OS's because of a couple of bad files.

A Brief History of Boot Loading

Booting up has a long and venerable history.  For the Microsoft family of OSs (DOS and Windows) the old scheme was to use the Master Boot Record (MBR) located on C:\boot.ini (as a hidden file).  There is also a good Manjaro Wiki  However this had the limitation of "only" being able to index 2 TB of data on a single volume so a new system was devised to future-proof Windows Vista and on, i.e. Windows 8, against truly massive drives.  This scheme is called Unified Extended Firmware Interface (UEFI) and instead of using a single file it uses an entire partition.  You will need to determine your boot loader scheme on Windows.  The scheme to edit UEFI is called the Boot Configuration Data Editor (BCD).  There is a Windows Help article about the back-story and another on the bcdedit utility.  The important take away point is that now a Windows Vista / Windows 8 system can boot up EITHER with UEFI OR the MBR and BCD was created to abstract away this underlying complexity.  This results in either having BCD with UEFI or BCD with the MBR.  However this turns out to be a leaky abstraction.

UEFI or MBR

As a rule of thumb, a computer bought after Windows Vista came out (2008?) will support UEFI.  Also you can dig around in the BIOS during boot up (to bring it up you may have to press F1, F10 or F12) looking for boot information.  In the BIOS MBR may be referred to as "legacy boot" or something similar.  Alternately you can just use msinfo32.

Pick Your Poison

Install and Fix

To modify the new UEFI scheme you need to use either the Windows utility command-line program bcdedit (run from the native shell, NOT a replacement like Console2, and as Administrator), the free-for-non-commercial-use easyBCD or the also free-for-commercial-use BootNext utility.  Unfortunately easyBCD only works with BCD over the MBR and BootNext requires you to register on the blog site to download.  The good news is that easyBCD is easy to use.

Using easyBCD (BCD / MBR)

After much searching and consternation I found an Ask Ubuntu post on how to dual boot Windows and Linux as well as an in depth walk-through on the easyBCD site.  Basically you install normally with the Advanced Partitioning, and then tell Windows how to find Ubuntu.  These posts let me boot to Ubuntu after poking through the boot menu after an error about being unable to find the /NST/AutoNeoGrub0.mbr file.  This happens when you use easyBCD with UEFI.

Using BootNext (BCD / UEFI)

While BootNext supports UEFI it appears to only have a help file for installing with Windows 7.  Also the method is complex as you have to load your Ubuntu partition under Windows and then copy 512 bytes of the boot sector.  This leads us to the option of having UEFI and installing it right to begin with.

Install it Right

It turns out that there was a hard-to-find article on installing Ubuntu alongside another OS with UEFI enabled at help.ubuntu.com and is far easier to understand than a similar Q&A page.  The critical part of this article is that when you install Ubuntu in "Advanced" mode to manage your system partitions you need to find your UEFI partition and mount it at /boot/efi.  You can find this partition by going into the Windows' Disk Management utility and look for a partition with a Status of "Healthy (EFI System Partition)" and note which partition this is (in my case, it was the second partition on the disk).  Remember to create a SWAP partition (1x or 2x as large as your RAM, see the FAQ) as well as your main Ubuntu partition (20 GB or more).

Conclusion

So, in this article we have seen the history of boot loaders, the different kinds of boot loaders and tools to work with them as well as how to install Ubuntu and then tell Windows about it or installing Ubuntu correctly in the first place.  This has been one of the more difficult articles that I have written and I hope that I distilled my research over about 30 different tutorials and Q&A pages into an easy to understand format.

Tuesday, April 29, 2014

Using JS Test Runner with slf4j-log4j12

Hello.

If you've tried using JS Test Runner to integrate your QUnit JavaScript unit tests with Maven you may have noticed that JS Test Runner has a transitive dependency to slf4j-jcl (Simple Logging Facade for Java with Jakarta Commons Logging bridge).  This is supposed to be easily fixed by using Maven's dependency exclusions but for some unknown reason this did not work for my project.  This resulted in two slf4j appenders being present at the same time, causing a warning from slf4j ("Multiple bindings were found on the class path").  A warning usually isn't too bad of a problem but it caused the Google App Engine to crash locally, making it a blocking issue.  I tried manually changing the POM file the Right Way by cloning the Git repository and trying to run `mvn install` on an incremented version of it, but it required GPG and that failed on my Windows 64bit machine ("Sorry, no terminal at all requested - can't get input").  So, out of desperation I "monkey-patched" the current POM (1.0.2) manually to use slf4j-log4j12 (like the rest of my project) instead of slf4j-jcl.  This has been working beautifully... but is a blatant hack.

In Summary, if you're having problems with JS Test Runner vis a vis logging you want to manually edit the POM file in your local repository (and document it in your project).

Tuesday, March 18, 2014

The Maven Central Archetype Catalog File

During the course of trying to look at the new Google App Engine Archetypes I found that they were in Maven Central... but Maven Central wasn't configured as an archetype source in my Eclipse installation.

It took some digging to find the Maven docs pointing to http://repo1.maven.org/maven2/archetype-catalog.xml so that I could add the catalog to my searched sites.  Good luck.

Friday, March 7, 2014

Shiro, Guice, Maven and Google App Engine Integration Quick Start Completed!

The Shiro, Guice, Maven and Google App Engine Integration Quick Start tutorial is now complete.  Blogger was having an issue where the usual "preview" feature was not working so I had to publicly post my work to ensure that it was displaying correctly.  For anyone who viewed the page before completion, you can now go back if you want to see the finished work.  Thanks for reading!