gpt4 book ai didi

java - DataNucleus 增强失败 - Android Studio 中的 GAE

转载 作者:行者123 更新时间:2023-11-29 04:40:54 27 4
gpt4 key购买 nike

我最近将一个 App Engine 项目从 Eclipse 迁移到了 Android Studio。不幸的是,appengineEnhance gradle 任务失败了。

我已经发现可能存在版本不匹配,因为 org.datanucleus.OMFContext 不应出现在 v2 库中。所以我猜有些依赖引用 datanucleus-...-1.1.5 而不是 datanucleus-...-3.1.3 但我无法解决这个问题。

使用 --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.

来自日志文件的堆栈跟踪:

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 文件:

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
}
}

编辑:我可以验证该进程正在使用 v1 jar(尽管应该使用 v2,如 build.gradle 中所述)。从 .gradle\appengine-sdk\appengine-java-sdk-1.9.42\lib\opt\tools\datanucleus 中删除 v1 文件夹时,任务失败并出现以下异常:

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)

最佳答案

好吧,原来这是一个 issue与最新版本的 App Engine Java SDK 相关。

降级线路

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

以下内容

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

解决了所有错误并且增强工作正常。

关于java - DataNucleus 增强失败 - Android Studio 中的 GAE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39245339/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com