Migrating to Java 11

This guide outlines a process you can follow to migrate your Google Cloud server code from Java 8 and the standalone App Engine SDK to Java 11 and the Cloud SDK.


This is a companion discussion topic for the original entry at https://happycoding.io/tutorials/google-cloud/migrating-to-java-11

This is really helpful. I have a legacy Java 8 app. I looked at migrating it couple years ago, but put it off as my datastore was not yet migrated to Firestore in Datastore mode. It has been migrated automatically by Google now. The other challenge was that I couldn’t get the logging to work properly.

Can you comment on how you implemented logging for your app?

Thanks!

1 Like

To be honest, for my own personal projects I don’t do much logging.

I know that print statements and other logging info goes to the logging tab in the Cloud console, so my usual approach is a good old fashioned System.out.println() and then to look there.

@Kevin I resolved the logging issue, but I’m facing several other challenges with this migration.

  1. I use Google Cloud Endpoints Framework with my Java 8 runtime app, but it’s not supported for Java 11 runtime. I have not found any information about a replacement.

  2. I have a GuiceServletContextListener to initialize my app. The approach is explained here: Configuring Warmup Requests to Improve Performance (unfortunately, I’m not allowed to share links on this forum). The listener is included in my web.xml. I have GuiceFilter also in the web.xml. So, is the web.xml still used? I don’t see my listener getting invoked. All my endpoints and servlet mappings are done using com.google.inject.servlet.ServletModule which are injected using GuiceServletContextListener.

It seems like I have to abandon this upgrade, and completely ditch GAE. :frowning:

Do you have any suggestions for me?

Thanks!

Honestly I don’t blame you. I was really frustrated when I migrated all my stuff.

None of my examples use web.xml to configure the Jetty web server, but my understanding is that this should still be possible. You might also be able to set up your listeners in your main method that runs the server.

Kevin, I have no words to appreciate the efforts that you may have gone through putting this guide together. I am in process of trying to migrate from Java 8 to Java 11 and have spent the last 20 hours with no demonstrate-able results.
Having said that, using your guide, I have reached a point where my jar gets deployed but fails immediately because of “java.lang.module.FindException: Unable to derive module descriptor for ./myWebApp.jar”. Turns out that, while migrating from Java 8 to Java 11, the projects also need to be modularized. Mine have not yet been and hence this error. Any thoughts?

1 Like

Thank you so much! The migration was such a headache for me, I totally get it.

I haven’t seen that particular error, but what I’d try to do if I were you is isolate the problem. Can you get a simple “hello world” project running with Java 11? Which exact part of your project is causing the error?

Kevin, Thanks a lot for your reply. I have gotten myself to a point where I have 2 output files…XYZ.jar (the ServerMain.class) and XYZ.war (my core appl classes). If you could have a look at stackoverflow, I have explained everything in details. This is my 5th day attempting to make this work but to no avail. If you could please have a look and be my guide.
I am unable to post the link to stackoverflow but my question there can be found by searching for the heading [Getting 404 when accessing classes annotated with @Path in {war}/WEB-INF/classes in Jetty 9]