Trying to run Enhance on Android Studio
Asked Answered
C

2

3

I'm trying to setup jdo/jpa in Android Studio and havefollowed an answer from a previous question here.

When I attempt to run the enhance task I get:

Error:Execution failed for task ':backend:appengineEnhance'.
An error occurred enhancing DataNucleus classes.

and the log file shows:

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

I thought this worked fine last week on my desktop but I'm trying to replicate it on my laptop and nothing appears to be working (cloned bitbucket repository). Here is my gradle:

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

repositories {
    mavenCentral();
}

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

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.1'
  compile 'com.google.appengine:appengine-endpoints:1.9.1'
  compile 'com.google.appengine:appengine-endpoints-deps:1.9.1'
  compile 'javax.servlet:servlet-api:2.5'

    // Persistence
    compile 'org.ow2.asm:asm:4.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'

}

appengine {
  downloadSdk = true
  appcfg {
    oauth2 = true
  }
  endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
  }
}
Cantal answered 26/5, 2014 at 23:55 Comment(2)
perhaps you want to use the v2 enhancer? #23375775Royster
Looks like that killed the error, thanks! Submit it as an answer so I can give you credit.Cantal
C
3

Per @loosebazooka above the answer is to use the v2 enhancer at the link in the comments above.

Cantal answered 31/5, 2014 at 21:4 Comment(1)
The answer should be self-contained.Fruit
A
3

I also faced this issue - the relevant parts of my build.gradle are shown below. Please note the addition of the api="jdo", without which I continued to get the same error as the OP.

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

war.dependsOn appengineEnhance

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.14'
    compile 'com.google.appengine:appengine-endpoints:1.9.14'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.14'
    compile 'com.google.appengine.orm:datanucleus-appengine:2.1.2'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.ganyo:gcm-server:1.0.2'
    compile 'javax.jdo:jdo2-api:2.3-eb'
    compile 'org.datanucleus:datanucleus-api-jdo:3.1.3'
}

appengine {
    enhancer {
        version = "v2"
        api="jdo"
        enhanceOnBuild = true
    }
}
Anhanhalt answered 24/1, 2015 at 17:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.