DataNucleus enhancing failed - GAE in Android Studio

24 views
Skip to first unread message

Steppschuh via StackOverflow

unread,
Aug 31, 2016, 5:18:04 AM8/31/16
to google-appengin...@googlegroups.com

I recently migrated an App Engine project from Eclipse to Android Studio. Unfortunately the appengineEnhance gradle task fails.

I already figured out that there might be a version mismatch, as org.datanucleus.OMFContext shouldn't be present in the v2 libs. So I guess that some dependency is referencing datanucleus-...-1.1.5 instead of datanucleus-...-3.1.3 but I'm not able to resolve this issue.

Log output with --info:

Executing task ':backend:appengineEnhance' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
App Engine SDK root = C:\Users\NTBDE\.gradle\appengine-sdk\appengine-java-sdk-1.9.42
Java classpath = C:\Users\NTBDE\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv\gradle-2.14.1\lib\gradle-launcher-2.14.1.jar;C:\Users\NTBDE\.gradle\appengine-sdk\appengine-java-sdk-1.9.42\lib\appengine-tools-api.jar
Webapp source directory = C:\Users\sschultz\Documents\Projects\IntelliQ\Android\IntelliQ\backend\src\main\webapp
Enhancing DataNucleus classes...
[ant:enhance] [newrelic.info] Deinstrumenting...
[ant:enhance] Encountered a problem: Unexpected exception
[ant:enhance] Please see the logs [C:\Users\sschultz\AppData\Local\Temp\enhance2770794418099399278.log] for further information.
Finished enhancing DataNucleus classes.
:backend:appengineEnhance FAILED
:backend:appengineEnhance (Thread[Daemon worker Thread 7,5,main]) completed. Took 0.589 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':backend:appengineEnhance'.
> An error occurred enhancing DataNucleus classes.

Stacktrace from log file:

java.lang.RuntimeException: Unexpected exception
    at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:76)
    at com.google.appengine.tools.enhancer.Enhance.<init>(Enhance.java:71)
    at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:51)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:74)
    ... 2 more
Caused by: java.lang.NoSuchMethodError: org.datanucleus.plugin.PluginManager.<init>(Lorg/datanucleus/PersistenceConfiguration;Lorg/datanucleus/ClassLoaderResolver;)V
    at org.datanucleus.OMFContext.<init>(OMFContext.java:159)
    at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:172)
    at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:150)
    at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157)
    ... 7 more

build.gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
    }
}

repositories {
    jcenter();
}

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

war.dependsOn appengineEnhance

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
    compile group: 'com.google.apis', name: 'google-api-services-oauth2', version: 'v1-rev120-1.22.0'
    compile group: 'com.google.http-client', name: 'google-http-client', version: '1.22.0'
    compile group: 'com.google.http-client', name: 'google-http-client-appengine', version: '1.22.0'
    compile group: 'com.google.http-client', name: 'google-http-client-jdo', version: '1.22.0'
    compile group: 'com.google.http-client', name: 'google-http-client-gson', version: '1.22.0'
    compile group: 'commons-io', name: 'commons-io', version: '2.5'
    compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.2'
    compile group: 'com.google.appengine.orm', name: 'datanucleus-appengine', version: '2.1.2'
    compile 'org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.0'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'javax.transaction:jta:1.1'
    compile 'com.google.code.gson:gson:2.4'
}


appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    enhancer {
        version = "v2"
        api="jdo"
        enhanceOnBuild = true
    }
}


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39245339/datanucleus-enhancing-failed-gae-in-android-studio

Steppschuh via StackOverflow

unread,
Aug 31, 2016, 7:18:06 AM8/31/16
to google-appengin...@googlegroups.com

Edit: I can verify that the process is using the v1 jars (although v2 should be used, as stated in build.gradle). When removing the v1 folder from .gradle\appengine-sdk\appengine-java-sdk-1.9.42\lib\opt\tools\datanucleus, the tasks fails with the following exception:

java.lang.NullPointerException: ormLibs cannot be null
    at com.google.appengine.tools.enhancer.EnhancerLoader.removeOrmLibs(EnhancerLoader.java:66)
    at com.google.appengine.tools.enhancer.EnhancerLoader.getClassPath(EnhancerLoader.java:43)
    at com.google.appengine.tools.enhancer.EnhancerLoader.<init>(EnhancerLoader.java:37)
    at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:69)
    at com.google.appengine.tools.enhancer.Enhance.<init>(Enhance.java:71)
    at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:51)

Buls via StackOverflow

unread,
Aug 31, 2016, 3:38:06 PM8/31/16
to google-appengin...@googlegroups.com

I had a similar issue. You need to add more dependencies for the enhancer. Here's my build.gradle file:

 /*
 * This build file was auto generated by running the Gradle 'init' task
 * by 'buls' at '8/30/16 11:36 PM' with Gradle 2.13
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * user guide available at https://docs.gradle.org/2.13/userguide/tutorial_java_projects.html
 */

// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

buildscript {
  repositories {
    mavenCentral()
  }

  dependencies {
    classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
  }
}

def appEmail = "${appEmail}"

repositories {
    jcenter()
}


dependencies {

    compile 'org.slf4j:slf4j-api:1.7.21'

    testCompile 'junit:junit:4.12'
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.0'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.0'
    compile 'com.google.code.gson:gson:2.2.2'
    compile 'commons-codec:commons-codec:1.10'
    compile 'org.json:json:20160810'

    compile 'org.ow2.asm:asm:4.0'    
    compile 'com.google.appengine:appengine-api-labs:1.9.0'    
    compile 'com.google.appengine:appengine-jsr107cache:1.9.0'
    compile 'org.datanucleus:datanucleus-api-jpa:3.1.3'
    compile 'org.datanucleus:datanucleus-api-jdo:3.1.3'
    compile 'com.google.appengine.orm:datanucleus-appengine:2.1.2'
    compile 'org.datanucleus:datanucleus-core:3.1.3'
    compile 'org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.0'
    compile 'javax.jdo:jdo-api:3.0.1'
    compile 'javax.transaction:jta:1.1'            
    compile 'net.sf.jsr107cache:jsr107cache:1.1'

}

appengine {
    httpPort = 8888
    downloadSdk = true
    appcfg {
        email = "${appEmail}"
        noCookies = false
        oauth2 = true
    }
    enhancer { 
        version = "v2"
        enhanceOnBuild = true 
        api = "jdo"
    }
}


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39245339/datanucleus-enhancing-failed-gae-in-android-studio/39257666#39257666

Steppschuh via StackOverflow

unread,
Sep 1, 2016, 1:23:05 PM9/1/16
to google-appengin...@googlegroups.com

Alright, turns out this is an issue related to the latest version of the App Engine Java SDK.

Downgrading the line

appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'

to the following

appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.0'

resolved all errors and the enhancing works fine.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39245339/datanucleus-enhancing-failed-gae-in-android-studio/39277472#39277472

Steppschuh via StackOverflow

unread,
Sep 1, 2016, 2:38:05 PM9/1/16
to google-appengin...@googlegroups.com

Alright, turns out this is an issue related to the latest version of the App Engine Java SDK.

Downgrading the line

appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'

to the following

appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.38'
Reply all
Reply to author
Forward
0 new messages