If you are still running a Java 6 application on Google AppEngine, you’re about to get into serious trouble. Any moment now, the AppEngine team is going to release version 1.8.9, which will no longer support deployment of Java 6 applications.
Existing applications will keep on running. But you should probably upgrade your application with the necessary urgency, as you will no longer be able to fix bugs.
Most PaaS providers will very regularly update their platform to keep up with the latest security fixes and to add on new services and APIs. In this regard AppEngine takes a pretty radical approach. They do not wait for their customers when they think removing old code is the right thing to do.
These updates will usually be backwards compatible, but, given enough time, there will be updates that break old code. Java 7 is backwards compatible with Java 6. But some libraries are not.
A Good Thing?
I try to see this maintenance work as a good thing. It forces you to keep up with the latest technology, which, as far as I’m concerned, is mostly important from a security standpoint.
Upgrading to Java 7 on Google’s AppEngine
So lets get into the details. In most cases, this upgrade will be as simple as changing the JDK that you use to build and deploy to AppEngine. In my case, it wasn’t.
The major problem was that some part of the JDO/DataNucleus/AppEngine combination I was using, did not work with Java 7. According to all of their respective pages, this should not be problem, but it just didn’t work with runtime errors that indicated incompatible versions.
I had been wanting to upgrade DataNucleus anyway, so I thought “Why not?” It turned into a prolonged session of yak shaving.
First, upgrade appengine-datanucleus, the integration library between AppEngine and DataNucleus. There are currently 3 versions. Only the latest version is using non-deprecated code. Sadly, this version is (as far as I know) not officially release yet. So after much consideration, I ended up picking version 2.1 (I hope to get rid of JDO in favor of Objectify this year)
Next I found out that this also means I need to migrate the datastore content. This is not very well documented at all. Even if you manage to find that wiki article, it’s using old libraries. I was unable to get this working on my project and didn’t have the time nor willpower to figure out the new mapreduce framework for AppEngine.
Eventually I created a small task queue that could perform the upgrade. Luckily the number of entities was small enough that this worked. If you have a larger dataset, you will probably already know how to use mapreduce anyway.
With that out of the way, there were still a few small bugs popping up. All of them were caught by my unit tests. For instance, it turns out that loading an empty collection from the datastore may now return null instead of an empty collection. Small thing to fix, but it would be nice if this was documented somewhere.
Make sure you take your time to do the Java 6 to 7 upgrade on AppEngine. It’s probably going to be transparent for you, but what if it isn’t?
Get ready to program in a whole new way!
Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.