在Java上使用Ant与Google App Engine时出错

时间:2013-12-09 19:10:55

标签: java google-app-engine ant datanucleus

我有一个用Java编写的Google App Engine应用程序,我正在尝试将其设置为与Travis持续集成服务器一起使用。作为这个过程的一部分,我需要使用ant自动化构建(以前,我刚刚使用Eclipse)。

在Google的App Engine文档中,他们为App Engine项目提供了完整的ant构建文件:

<project>
  <property name="sdk.dir" location="../appengine-java-sdk" />

  <import file="${sdk.dir}/config/user/ant-macros.xml" />

  <path id="project.classpath">
    <pathelement path="war/WEB-INF/classes" />
    <fileset dir="war/WEB-INF/lib">
      <include name="**/*.jar" />
    </fileset>
    <fileset dir="${sdk.dir}/lib">
      <include name="shared/**/*.jar" />
    </fileset>
  </path>

  <target name="copyjars"
      description="Copies the App Engine JARs to the WAR.">
    <copy
        todir="war/WEB-INF/lib"
        flatten="true">
      <fileset dir="${sdk.dir}/lib/user">
        <include name="**/*.jar" />
      </fileset>
    </copy>
  </target>

  <target name="compile" depends="copyjars"
      description="Compiles Java source and copies other source files to the WAR.">
    <mkdir dir="war/WEB-INF/classes" />
    <copy todir="war/WEB-INF/classes">
      <fileset dir="src">
        <exclude name="**/*.java" />
      </fileset>
    </copy>
    <javac
        srcdir="src"
        destdir="war/WEB-INF/classes"
        classpathref="project.classpath"
        debug="on" />
  </target>

  <target name="datanucleusenhance" depends="compile"
      description="Performs JDO enhancement on compiled data classes.">
    <enhance_war war="war" />
  </target>

  <target name="runserver" depends="datanucleusenhance"
      description="Starts the development server.">
    <dev_appserver war="war" />
  </target>

  <target name="update" depends="datanucleusenhance"
      description="Uploads the application to App Engine.">
    <appcfg action="update" war="war" />
  </target>

  <target name="update_indexes" depends="datanucleusenhance"
      description="Uploads just the datastore index configuration to App Engine.">
    <appcfg action="update_indexes" war="war" />
  </target>

  <target name="rollback" depends="datanucleusenhance"
      description="Rolls back an interrupted application update.">
    <appcfg action="rollback" war="war" />
  </target>

  <target name="request_logs"
      description="Downloads log data from App Engine for the application.">
    <appcfg action="request_logs" war="war">
      <options>
        <arg value="--num_days=5"/>
      </options>
      <args>
        <arg value="logs.txt"/>
      </args>
    </appcfg>
  </target>

</project>

我尝试将此verbatum粘贴到使用Eclipse生成的新应用引擎项目的build.xml文件中并运行它(当然,在将应用引擎sdk复制到适当的位置之后),但我得到以下内容错误:

$ ant runserver
Buildfile: c:\Users\Ajedi32\Documents\Ajedi32\ant_test\build
xml

copyjars:
     [copy] Copying 7 files to c:\Users\Ajedi32\Documents\Ajedi32\ant_test\war\WEB-INF\lib

compile:
    [javac] c:\Users\Ajedi32\Documents\Ajedi32\ant_test\build.xml:39: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

datanucleusenhance:
  [enhance] Encountered a problem: Unexpected exception
  [enhance] Please see the logs [C:\Users\Ajedi32\AppData\Local\Temp\enhance5135186886756266241.log] for further information.

BUILD FAILED
c:\Users\Ajedi32\Documents\Ajedi32\ant_test\build.xml:44: The following error occurred while executing this line:
c:\Users\Ajedi32\Documents\Ajedi32\appengine-java-sdk-1.8.8\config\user\ant-macros.xml:95: Java returned: 1

Total time: 4 seconds

C:\Users\Ajedi32\AppData\Local\Temp\enhance5135186886756266241.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:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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

出了什么问题? Google的build.xml文件错了吗?我以前从未使用过ant,而且我仍然是使用Java和App Engine进行生产质量应用的新手,所以我完全迷失在这里......

如果有人曾经将App Engine设置为与ant合作,我真的很想知道你是如何做到的。具有工作ant构建的app引擎应用程序的示例将很好......

0 个答案:

没有答案