我正在尝试构建我的第一个 Google App Engine WAR,并且正在设置我自己的外部(Eclipse 之外)Ant 构建以从终端执行。我正在尝试获取 <enhance_war/>
Ant 宏正在运行,我遇到了一个奇怪的问题 NoSuchMethodError
.
这是我的 Ant 目标:
<target name="package" depends="gendocs">
<echo message="Enhancing WAR JDO classes." />
<enhance_war war="war" />
<echo message="Packaging the WAR file." />
<war destfile="gen/dist/myapp.war" webxml="war/web.xml">
<fileset dir="war">
<includes name="**/*.xml" />
</fileset>
<lib dir="war/WEB-INF/lib" />
<classes dir="war/WEB-INF/classes" />
</war>
</target>
这是 Ant 尝试执行 package
时的输出目标:
package:
[echo] Enhancing WAR JDO classes.
[enhance] Encountered a problem: Unexpected exception
[enhance] Please see the logs [/tmp/enhance4426322586552955387.log] for further information.
BUILD FAILED
/home/myuser/sandbox/workbench/eclipse/workspace/myapp/build/build-local.xml:193: The following error occurred while executing this line:
/home/myuser/sandbox/workbench/google/gae-sdk/1.7.1/appengine-java-sdk-1.7.1/config/user/ant-macros.xml:95: Java returned: 1
那个ant-macros.xml:95
对应以下行:
<enhance failonerror="true" api="@{api}">
<!-- Rest of the enhance task def -->
</enhance>
执行此 <enhance />
时出现问题任务,但我不知道是什么。
最后是 /tmp/enhance4426322586552955387.log
处的日志文件:
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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
这是怎么回事?我认为不是类路径问题,因为 org.datanucleus.plugin.PluginManager
类在 datanucleus-core-1.1.5.jar
中定义,我在构建类路径中绝对有。加上它的 NoSuchMethodError
,所以这让我觉得我遇到了 JAR hell /版本控制问题。有什么想法吗?
最佳答案
您的类路径中的 datanucleus-core 版本与增强器所需版本不同。验证增强器正在使用什么并修复它。参见 http://code.google.com/p/datanucleus-appengine/wiki/Compatibility兼容性要求。
最新的 GAE SDK 提供了“GAE JDO 插件”v2.1.1 IIRC,它是最新版本(虽然还有更近期的 fwiw 尚未发布),它位于 lib/opt/blahblahblah 下。这利用了 DataNucleus v3.1.x。这是建议人们反对的。 GAE JDO 插件开发于 http://code.google.com/p/datanucleus-appengine/
关于java - Google App Engine JDO 增强失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14554774/