3
votes

I'm trying to migrate Google App Engine to java8 using the migration guide below.

https://cloud.google.com/appengine/docs/standard/java/migrating-to-java8

it says that: -

To have App Engine run your application in the Java 8 runtime, add
<runtime>java8</runtime>
to your appengine-web.xml file and redeploy the app.

when i try to do that i get the following error at the "runtime" tag:

element runtime is not allowed here

did i miss anything? This GAE is a backend module for my android app. I am using gradle on Android studio as the development environment.

prior to this, I have also migrated successfully to cloudEndpoints V2 using https://cloud.google.com/endpoints/docs/frameworks/java/migrating

enter image description here

edit: added error log

Jan 03, 2018 3:39:52 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
SEVERE: Received exception processing D:\GitlabProjects\XushuNarrator\backend\build\exploded-backend\WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Unrecognized element <runtime>
    at com.google.apphosting.utils.config.AppEngineWebXmlProcessor.processSecondLevelNode(AppEngineWebXmlProcessor.java:183)
    at com.google.apphosting.utils.config.AppEngineWebXmlProcessor.processXml(AppEngineWebXmlProcessor.java:65)
    at com.google.apphosting.utils.config.AppEngineWebXmlReader.processXml(AppEngineWebXmlReader.java:132)
    at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:76)
    at com.google.apphosting.utils.config.EarHelper.readWebModule(EarHelper.java:165)
    at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.readConfiguration(ApplicationConfigurationManager.java:414)
    at com.google.appengine.tools.development.ApplicationConfigurationManager.<init>(ApplicationConfigurationManager.java:159)

edit 2: the following is the gradle build for the backend. (After migration from V1 to V2)

//MIGRATION GUIDE
//https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        // V2: Add the new App Engine and Endpoints Frameworks plugin dependencies
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'

//         classpath 'com.google.appengine:gradle-appengine-plugin:1.9.59'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
// V2: Apply new App Engine and Endpoints Framework server plugins
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
//apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
//    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.59'
//    compile 'com.google.appengine:appengine-endpoints:1.9.59'
//    compile 'com.google.appengine:appengine-endpoints-deps:1.9.59'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.googlecode.objectify:objectify:5.1.9'

    compile 'javax.inject:javax.inject:1'

    // V2: Endpoints Framework v2 migration
    compile 'com.google.endpoints:endpoints-framework:2.0.7'

}

// V2: Define deployment configuration using the new App Engine plugin
// with the appengine closure
appengine {  // App Engine tasks configuration

    deploy {   // deploy configuration

        // The following is used for acceptance tests and
        // is not required for a migration. 
        project = "ultra-tube-89909"
        version = "2" //changed to GAE API v2

        /*
        Run the following command to initalize the Cloud SDK:
             gcloud init
        Use Application Default Credentials:
             gcloud auth application-default login
        Install the app-engine-java component:
             gcloud components install app-engine-java
         */
//        project = findProperty("appengine.deploy.project")
//        version = findProperty("appengine.deploy.version")

        def promoteProp = findProperty("appengine.deploy.promote")
        if (promoteProp != null) {
            promote = new Boolean(promoteProp)
        }
    }
}
2
can you please post your Gradle Build file? - Michael Meyer
I have just tested with a sample application adding the <runtime>java8</runtime> tag and it works for me. Are you working with App Engine Standard or Flexible? The error comes up on deployment or when local-testing the app with the Development Server? - dsesto

2 Answers

2
votes

It's highly advised to keep the Google Cloud SDK up to date as there are bug fixes and new features introduced quite often. So, I recommend that you to update your Cloud SDK version by the running the following command:

gcloud components update

Also, according to the migration documentation the following change is needed to upgrade the Gradle App Engine plugin, so that it may recognize the new ‘Java8’ runtime:

classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
1
votes

I had the exact same thing but even though I had the error

element runtime is not allowed here

I still redeployed the backend via Gradle and it all worked. Then when I check my google cloud console, the newly deployed app engine version has java 8 listed as the run time and my app still works. So all seems ok.