1

We received an email from Google App Engine to upgrade to Java 8 from Java 7. We have followed the steps in:

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

But after deploying our App Engine back-end it fails to start with the following error:

org.datanucleus.metadata.MetaDataManager initialiseFileMetaDataForUse: Found Meta-Data for class ... but this class is not enhanced!! Please enhance the class before running DataNucleus. (MetaDataManager.java:1144) org.datanucleus.exceptions.NucleusUserException: Found Meta-Data for class ... but this class is not enhanced!! Please enhance the class before running DataNucleus. at org.datanucleus.metadata.MetaDataManager.initialiseClassMetaData(MetaDataManager.java:2593) at org.datanucleus.metadata.MetaDataManager.initialiseFileMetaData(MetaDataManager.java:2544) at org.datanucleus.metadata.MetaDataManager.initialiseFileMetaDataForUse(MetaDataManager.java:1140) at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:986) at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialiseNucleusContext(JPAEntityManagerFactory.java:754) at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialise(JPAEntityManagerFactory.java:417) at org.datanucleus.api.jpa.JPAEntityManagerFactory.(JPAEntityManagerFactory.java:380) at org.datanucleus.api.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:91) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:150) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:70)

This is our build.gradle:

buildscript {    // Configuration for building
    repositories {
        mavenCentral()
        jcenter()    // Bintray's repository - a fast Maven Central mirror & more
    }
    dependencies {
        // App Engine Gradle plugin
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
    }
}

repositories {
    mavenCentral()
    jcenter()
}

apply plugin: 'java'
apply plugin: 'war'
//apply plugin: 'appengine'

apply plugin: 'com.google.cloud.tools.appengine'  // App Engine tasks
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

appengine {  // App Engine tasks configuration
    deploy {   // deploy configuration
        version = findProperty("appengine.deploy.version")

        def promoteProp = findProperty("appengine.deploy.promote")
        if (promoteProp != null) {
            promote = new Boolean(promoteProp)
        }
    }
}

configurations {
    compile.exclude module: 'guava-jdk5'
}

dependencies {
    implementation 'jstl:jstl:1.2'

    implementation group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '+'
    implementation group: 'com.google.endpoints', name: 'endpoints-framework', version: '+'

    implementation 'com.google.appengine.orm:datanucleus-appengine:+' //2.1.2'

    implementation 'javax.servlet:servlet-api:2.5'
    implementation 'javax.inject:javax.inject:1'
    implementation 'javax.transaction:jta:1.1'
    implementation 'com.ganyo:gcm-server:1.0.2'
    implementation 'org.json:json:20140107'
    implementation 'org.apache.httpcomponents:httpmime:+'
    implementation 'org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.0'

    // Persistence
    //    implementation 'org.ow2.asm:asm:4.0'
    implementation 'javax.jdo:jdo-api:+' //3.0.1'
    implementation 'org.datanucleus:datanucleus-api-jpa:3.1.3'
    implementation 'org.datanucleus:datanucleus-api-jdo:3.1.3' //5.0.1'
    implementation 'org.datanucleus:datanucleus-enhancer:+' //3.1.1'
    implementation 'org.datanucleus:datanucleus-core:3.1.3'

    implementation 'org.hibernate:hibernate-validator:5.2.4.Final'

    implementation 'com.google.api-client:google-api-client:+'
    implementation 'com.google.api-client:google-api-client-android:+'
    implementation 'com.google.http-client:google-http-client:+'
    implementation 'com.google.http-client:google-http-client-android:+'
}

task datanucleusEnhance {
    description "Enhance JPA model classes using DataNucleus Enhancer"
    dependsOn compileJava

    doLast {
        // define the entity classes
        def entityFiles = fileTree(sourceSets.main.output.classesDir).matching {
            include '/*.class'
        }

        println "Enhancing with DataNucleus the following files"
        entityFiles.getFiles().each {
            println it
        }

        // define Ant task for DataNucleus Enhancer
        ant.taskdef(
                name : 'datanucleusenhancer',
                classpath : sourceSets.main.runtimeClasspath.asPath,
//                classname : 'org.datanucleus.enhancer.EnhancerTask'
                // the below is for DataNucleus Enhancer 3.1.1
                classname : 'org.datanucleus.enhancer.tools.EnhancerTask'
        )

        // run the DataNucleus Enhancer as an Ant task
        ant.datanucleusenhancer(
                classpath: sourceSets.main.runtimeClasspath.asPath,
                verbose: true,
                api: "JDO") {
            entityFiles.addToAntBuilder(ant, 'fileset', FileCollection.AntType.FileSet)
        }
    }
}

classes.dependsOn(datanucleusEnhance)

This works as soon as we switch back to Java 7.

Machavity
  • 30,841
  • 27
  • 92
  • 100
doctorram
  • 1,112
  • 14
  • 13
  • your error doesnt say anything about enhancement not working. Post the output from the enhancer. And use a java decompiler on your classes to see if enhancement "works" –  Apr 29 '18 at 07:21
  • Where do I find the enhancer logs? Isn't it in the GAE developer console? – doctorram Apr 29 '18 at 15:01
  • wherever you configured the logging to go to when you run it –  Apr 29 '18 at 15:05
  • I don't know where to configure enhancer logs location... – doctorram Apr 30 '18 at 03:30
  • Why not look at the documentation for the "enhancer" and look at the specification of a Log4J configuration file? –  Apr 30 '18 at 06:06
  • Were you able to solve it? [This](https://stackoverflow.com/questions/45493314/enhancing-endpoints-in-cloud-endpoints-frameworks-2-0-for-app-engine?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) looks exactly like the issue you have. – A.Queue May 19 '18 at 13:47
  • Not really. I did a hack instead. I upgraded to Java 8 but turned on compatibility with Java 7! – doctorram May 19 '18 at 17:26
  • You could post this as a solution here then! May as well get yourself a few points. – A.Queue May 20 '18 at 08:11

0 Answers0