2013-09-27 50 views
0

我将文章称为here,它定义了如何增强数据核的类。我试图使用Maven做相同的,但不断获取构建失败在GAE中使用Maven进行Datanucleus增强,构建失败

DataNucleus Enhancer (version 3.2.7) for API "JPA" using JRE "1.7" 
DataNucleus Enhancer : Classpath 
>> E:\DevTools\apache-maven-3.1.0\bin\..\boot\plexus-classworlds-2.4.2.jar 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3.262s 
[INFO] Finished at: Fri Sep 27 22:41:16 IST 2013 
[INFO] Final Memory: 17M/227M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.datanucleus:datanucleus-maven-plugin:3.2.0-m2:enhance (default) on project rho_v1.0: Error executing DataNucleus tool org.datanucleus.en 
hancer.DataNucleusEnhancer: InvocationTargetException: org.datanucleus.metadata.AbstractMemberMetaData.setPersistenceModifier(Ljava/lang/String;)V -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

我的POM文件是如下

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 
    <packaging>war</packaging> 
    <version>1.0-SNAPSHOT</version> 

    <groupId>com.sis.rho</groupId> 
    <artifactId>rho_v1.0</artifactId> 

    <properties> 
     <appengine.app.version>1</appengine.app.version> 
     <appengine.target.version>1.8.3</appengine.target.version> 
     <datanucleus-core.version>3.2.7</datanucleus-core.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <!-- Compile/runtime dependencies --> 
     <dependency> 
      <groupId>com.google.appengine</groupId> 
      <artifactId>appengine-api-1.0-sdk</artifactId> 
      <version>${appengine.target.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>jstl</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 

     <!-- Test Dependencies --> 
     <dependency> 
      <groupId>com.google.appengine</groupId> 
      <artifactId>appengine-testing</artifactId> 
      <version>${appengine.target.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.google.appengine</groupId> 
      <artifactId>appengine-api-stubs</artifactId> 
      <version>${appengine.target.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <!-- Struts 2 --> 
     <dependency> 
      <groupId>org.apache.struts</groupId> 
      <artifactId>struts2-core</artifactId> 
      <version>2.1.8</version> 
     </dependency> 

     <!-- Spring framework --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring</artifactId> 
      <version>2.5.6</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>2.5.6</version> 
     </dependency> 

     <!-- Struts 2 + Spring plugins --> 
     <dependency> 
      <groupId>org.apache.struts</groupId> 
      <artifactId>struts2-spring-plugin</artifactId> 
      <version>2.1.8</version> 
     </dependency> 

     <!-- Javax persistence --> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-core</artifactId> 
      <version>${datanucleus-core.version}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-enhancer</artifactId> 
      <version>3.1.0-release</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.geronimo.specs</groupId> 
      <artifactId>geronimo-jpa_2.0_spec</artifactId> 
      <version>1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-api-jpa</artifactId> 
      <version>3.1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>com.google.appengine.orm</groupId> 
      <artifactId>datanucleus-appengine</artifactId> 
      <version>2.1.1</version> 
     </dependency> 

     <!-- for log4J --> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>1.6.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>jcl-over-slf4j</artifactId> 
      <version>1.6.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>1.6.1</version> 
     </dependency> 

     <!-- struts 2 velocity dependency --> 
     <dependency> 
      <groupId>org.apache.velocity</groupId> 
      <artifactId>velocity</artifactId> 
      <version>1.6.2</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <version>2.5.1</version> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.3</version> 
       <configuration> 
        <archiveClasses>true</archiveClasses> 
        <webResources> 
         <!-- in order to interpolate version from pom into appengine-web.xml --> 
         <resource> 
          <directory>${basedir}/src/main/webapp/WEB-INF</directory> 
          <filtering>true</filtering> 
          <targetPath>WEB-INF</targetPath> 
         </resource> 
        </webResources> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>com.google.appengine</groupId> 
       <artifactId>appengine-maven-plugin</artifactId> 
       <version>${appengine.target.version}</version> 
       <configuration> 
        <enableJarClasses>false</enableJarClasses> 
        <jvmFlags> 
         <jvmFlag>-Xdebug</jvmFlag> 
         <jvmFlag>-Xrunjdwp:transport=dt_socket,address=8080,server=y,suspend=y</jvmFlag> 
        </jvmFlags> 
        <disableUpdateCheck>true</disableUpdateCheck> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.datanucleus</groupId> 
       <artifactId>datanucleus-maven-plugin</artifactId> 
       <version>3.2.0-m2</version> 
       <configuration> 
        <api>JPA</api> 
        <fork>false</fork> 
        <persistenceUnitName>transactions-optional</persistenceUnitName> 
        <verbose>true</verbose> 
       </configuration> 
       <executions> 
        <execution> 
         <phase>process-classes</phase> 
         <goals> 
          <goal>enhance</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

任何人都可以请帮助我理解那有什么错误的手段,以及如何避免那个错误。任何帮助将不胜感激。

+0

JPA是否也需要增强? –

+0

当我不添加datanucleus maven插件增强我的构建是成功的,但我在创建'EntityManagerFactory'时发生错误**“找到类com.sis.rho.LoginBean的元数据,但这个类没有增强!”* * – S4beR

+1

使用不一致版本的(datanucleus)罐子,这就是你得到的结果 – DataNucleus

回答