2015-05-11 2 views
3

Мой код соответствует, но когда я пытаюсь запустить Enhancer DataNucleus, я не могу завершить этап компиляции сообщения. Я предполагаю, что мне не хватает файла jar, но какой? Я включил ошибку и pom.xmlDataNucleus enchancer не может создать экземпляр org.datanucleus.api.jdo.JDOAdapter

Я скопировать инструкции на страницах Google:

<plugin> 
<groupId>org.datanucleus</groupId> 
<artifactId>maven-datanucleus-plugin</artifactId> 
<version>3.2.0-m1</version> 
<configuration> 
<api>JDO</api> 
<props>${basedir}/datanucleus.properties</props> 
<verbose>true</verbose> 
<enhancerName>ASM</enhancerName> 
</configuration> 
<executions> 
<execution> 
<phase>process-classes</phase> 
<goals> 
<goal>enhance</goal> 
</goals> 
</execution> 
</executions> 
<dependencies> 
<dependency> 
<groupId>org.datanucleus</groupId> 
<artifactId>datanucleus-api-jdo</artifactId> 
<version>3.1.3</version> 
</dependency> 
</dependencies> 
</plugin> 

И я получаю эту ошибку.

 
And I get this error. 
    [ERROR] -------------------- 
    [ERROR] Standard error from the DataNucleus tool + org.datanucleus.enhancer.DataNucleusEnhancer : 
    [ERROR] -------------------- 
    [ERROR] Exception in thread "main" Error : An error occurred trying to  instantiate an instance of the API adapter "org.datanucleus.api.jdo.JDOAdapter" (perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH, or the 
    jar for the persistence spec you are using?) : {1} 
org.datanucleus.exceptions.NucleusUserException: Error : An error occurred trying to instantiate an instance of the A 
adapter "org.datanucleus.api.jdo.JDOAdapter" (perhaps you dont have the requisite datanucleus-api-XXX jar in the CLAS 
TH, or the api jar for the persistence spec you are using?) : {1} 
     at org.datanucleus.api.ApiAdapterFactory.getApiAdapter(ApiAdapterFactory.java:104) 
     at org.datanucleus.AbstractNucleusContext.(AbstractNucleusContext.java:115) 
     at org.datanucleus.enhancer.EnhancementNucleusContextImpl.(EnhancementNucleusContextImpl.java:48) 
     at org.datanucleus.enhancer.EnhancementNucleusContextImpl.(EnhancementNucleusContextImpl.java:37) 
     at org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:161) 
     at org.datanucleus.enhancer.CommandLineHelper.createDataNucleusEnhancer(CommandLineHelper.java:148) 
     at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1108) 

<?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" 
 
\t xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
 

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

 
\t <groupId>com.thechrisoneil.mygroupstogo</groupId> 
 
\t <artifactId>mygroupstogo</artifactId> 
 

 
\t <properties> 
 
\t \t <appengine.app.version>1</appengine.app.version> 
 
\t \t <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
 
\t </properties> 
 

 
\t <prerequisites> 
 
\t \t <maven>3.1.0</maven> 
 
\t </prerequisites> 
 

 
\t <dependencies> 
 
\t \t <!-- Compile/runtime dependencies, as defined by Google default maven project --> 
 
\t \t <!-- https://cloud.google.com/appengine/docs/java/tools/maven --> 
 
\t \t <dependency> 
 
\t \t \t <groupId>com.google.appengine</groupId> 
 
\t \t \t <artifactId>appengine-api-1.0-sdk</artifactId> 
 
\t \t \t <version>1.9.18</version> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>com.google.appengine</groupId> 
 
\t \t \t <artifactId>appengine-endpoints</artifactId> 
 
\t \t \t <version>1.9.18</version> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>javax.servlet</groupId> 
 
\t \t \t <artifactId>servlet-api</artifactId> 
 
\t \t \t <version>2.5</version> 
 
\t \t \t <scope>provided</scope> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>javax.inject</groupId> 
 
\t \t \t <artifactId>javax.inject</artifactId> 
 
\t \t \t <version>1</version> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>javax.jdo</groupId> 
 
\t \t \t <artifactId>jdo-api</artifactId> 
 
\t \t \t <version>3.1.3</version> 
 
\t \t </dependency> 
 
\t \t <!-- Dependencies added for datastorage persistents --> 
 
\t \t <!-- Datanucleaus (http://www.datanucleus.org/products/datanucleus/jdo/maven.html) --> 
 
\t \t <dependency> 
 
\t \t \t <groupId>com.google.appengine.orm</groupId> 
 
\t \t \t <artifactId>datanucleus-appengine</artifactId> 
 
\t \t \t <version>2.1.2</version> 
 
\t \t </dependency> 
 
     <dependency> 
 
      <groupId>org.datanucleus</groupId> 
 
      <artifactId>datanucleus-core</artifactId> 
 
      <version>3.1.3</version> 
 
      <scope>runtime</scope> 
 
     </dependency> 
 
     <dependency> 
 
      <groupId>org.datanucleus</groupId> 
 
      <artifactId>datanucleus-api-jdo</artifactId> 
 
      <version>3.1.3</version> 
 
     </dependency>  
 
     
 

 
\t \t <!-- Test Dependencies --> 
 
\t \t <dependency> 
 
\t \t \t <groupId>junit</groupId> 
 
\t \t \t <artifactId>junit</artifactId> 
 
\t \t \t <version>4.11</version> 
 
\t \t \t <scope>test</scope> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>org.mockito</groupId> 
 
\t \t \t <artifactId>mockito-all</artifactId> 
 
\t \t \t <version>1.9.5</version> 
 
\t \t \t <scope>test</scope> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>com.google.appengine</groupId> 
 
\t \t \t <artifactId>appengine-testing</artifactId> 
 
\t \t \t <version>1.9.18</version> 
 
\t \t \t <scope>test</scope> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>com.google.appengine</groupId> 
 
\t \t \t <artifactId>appengine-api-stubs</artifactId> 
 
\t \t \t <version>1.9.18</version> 
 
\t \t \t <scope>test</scope> 
 
\t \t </dependency> 
 
\t \t <dependency> 
 
\t \t \t <groupId>javax.jdo</groupId> 
 
\t \t \t <artifactId>jdo-api</artifactId> 
 
\t \t \t <version>3.0.1</version> 
 
\t \t </dependency> 
 
\t </dependencies> 
 

 
\t <build> 
 
\t \t <!-- for hot reload of the web application --> 
 
\t \t <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> 
 
\t \t <plugins> 
 
\t \t \t <plugin> 
 
\t \t \t \t <groupId>org.codehaus.mojo</groupId> 
 
\t \t \t \t <artifactId>versions-maven-plugin</artifactId> 
 
\t \t \t \t <version>2.1</version> 
 
\t \t \t \t <executions> 
 
\t \t \t \t \t <execution> 
 
\t \t \t \t \t \t <phase>compile</phase> 
 
\t \t \t \t \t \t <goals> 
 
\t \t \t \t \t \t \t <goal>display-dependency-updates</goal> 
 
\t \t \t \t \t \t \t <goal>display-plugin-updates</goal> 
 
\t \t \t \t \t \t </goals> 
 
\t \t \t \t \t </execution> 
 
\t \t \t \t </executions> 
 
\t \t \t </plugin> 
 
\t \t \t <plugin> 
 
\t \t \t \t <groupId>org.apache.maven.plugins</groupId> 
 
\t \t \t \t <version>3.1</version> 
 
\t \t \t \t <artifactId>maven-compiler-plugin</artifactId> 
 
\t \t \t \t <configuration> 
 
\t \t \t \t \t <source>1.7</source> 
 
\t \t \t \t \t <target>1.7</target> 
 
\t \t \t \t </configuration> 
 
\t \t \t </plugin> 
 
\t \t \t <plugin> 
 
\t \t \t \t <groupId>org.apache.maven.plugins</groupId> 
 
\t \t \t \t <artifactId>maven-war-plugin</artifactId> 
 
\t \t \t \t <version>2.4</version> 
 
\t \t \t \t <configuration> 
 
\t \t \t \t \t <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml> 
 
\t \t \t \t \t <webResources> 
 
\t \t \t \t \t \t <resource> 
 
\t \t \t \t \t \t \t <!-- this is relative to the pom.xml directory --> 
 
\t \t \t \t \t \t \t <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory> 
 
\t \t \t \t \t \t \t <!-- the list has a default value of ** --> 
 
\t \t \t \t \t \t \t <includes> 
 
\t \t \t \t \t \t \t \t <include>WEB-INF/*.discovery</include> 
 
\t \t \t \t \t \t \t \t <include>WEB-INF/*.api</include> 
 
\t \t \t \t \t \t \t </includes> 
 
\t \t \t \t \t \t </resource> 
 
\t \t \t \t \t \t <!--Development of groupstogo front end is imported to deployment server --> 
 
\t \t \t \t \t \t <resource> 
 
\t \t \t \t \t \t \t <directory>C:/software/angularjs/my-gtg/app</directory> 
 
\t \t \t \t \t \t \t <filtering>true</filtering> 
 
\t \t \t \t \t \t \t <includes> 
 
\t \t \t \t \t \t \t \t <include>**/*.js</include> 
 
\t \t \t \t \t \t \t \t <include>**/*.html</include> 
 
\t \t \t \t \t \t \t \t <include>**/*.png</include> 
 
\t \t \t \t \t \t \t \t <include>**/*.css</include> 
 
\t \t \t \t \t \t \t </includes> 
 
\t \t \t \t \t \t \t <targetPath>app</targetPath> 
 
\t \t \t \t \t \t </resource> 
 
\t \t \t \t \t \t 
 
\t \t \t \t \t </webResources> 
 
\t \t \t \t </configuration> 
 
\t \t \t </plugin> 
 
\t \t \t <plugin> 
 
\t \t \t \t <groupId>com.google.appengine</groupId> 
 
\t \t \t \t <artifactId>appengine-maven-plugin</artifactId> 
 
\t \t \t \t <version>1.9.18</version> 
 
\t \t \t \t <configuration> 
 
\t \t \t \t \t <enableJarClasses>false</enableJarClasses> 
 
\t \t \t \t \t <!-- Comment in the below snippet to bind to all IPs instead of just 
 
\t \t \t \t \t \t localhost --> 
 
\t \t \t \t \t <!-- address>0.0.0.0</address> <port>8080</port --> 
 
\t \t \t \t \t <!-- Comment in the below snippet to enable local debugging with a remove 
 
\t \t \t \t \t \t debugger like those included with Eclipse or IntelliJ --> 
 
\t \t \t \t \t <!-- jvmFlags> <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag> 
 
\t \t \t \t \t \t </jvmFlags --> 
 
\t \t \t \t </configuration> 
 
\t \t \t \t <executions> 
 
\t \t \t \t \t <execution> 
 
\t \t \t \t \t \t <goals> 
 
\t \t \t \t \t \t \t <goal>endpoints_get_discovery_doc</goal> 
 
\t \t \t \t \t \t </goals> 
 
\t \t \t \t \t </execution> 
 
\t \t \t \t </executions> 
 
\t \t \t </plugin> 
 
\t \t \t <plugin> 
 
       <groupId>org.datanucleus</groupId> 
 
       <artifactId>maven-datanucleus-plugin</artifactId> 
 
       <version>3.2.0-m1</version> 
 
       <configuration> 
 
        <api>JDO</api> 
 
        <props>${basedir}/datanucleus.properties</props> 
 
        <verbose>true</verbose> 
 
        <enhancerName>ASM</enhancerName> 
 
       </configuration> 
 
       <executions> 
 
        <execution> 
 
         <phase>process-classes</phase> 
 
         <goals> 
 
          <goal>enhance</goal> 
 
         </goals> 
 
        </execution> 
 
       </executions> 
 
       <dependencies> 
 
        <dependency> 
 
         <groupId>org.datanucleus</groupId> 
 
         <artifactId>datanucleus-api-jdo</artifactId> 
 
         <version>3.1.3</version> 
 
        </dependency> 
 
       </dependencies> 
 
      </plugin> 
 
\t \t </plugins> 
 
\t </build> 
 

 
</project>

+0

Почему бы вам использовать datanucleus-core/datanucleus-json из v4.x с datanucleus-api-jdo v3.1.x и datanucleus Maven плагин v3.2.x ??! Совершенно непоследовательно. –

+0

О, и нет такой вещи, как «javax.jdo» jdo-api v3.1.3. –

+0

Какова ваша рекомендация по правильным версиям? Вот что GAE рекомендовал на их [link] (https://cloud.google.com/appengine/docs/java/datastore/jdo/overview-dn2#Copying_the_JARs) веб-сайте: ' org.datanucleus datanucleus- api-jdo 3.1.3 ' – TheChrisONeil

ответ

4

У меня была такая же проблема, и был в состоянии решить путем сравнения https://cloud.google.com/appengine/docs/java/datastore/jdo/overview-dn2 и http://www.datanucleus.org/products/accessplatform_3_2/jdo/maven.html

Там может быть простой опечатка в ПОМ от Google .xml фрагмент. Как вы можете прочитать на странице DataNucleus, плагин maven будет автоматически использовать последнее доступное ядро ​​datanucleus. Чтобы предотвратить это использование:

<plugin> 
    <groupId>org.datanucleus</groupId> 
    <artifactId>datanucleus-maven-plugin</artifactId> 
    <version>3.2.0-release</version> 
    <configuration> 
     <api>JDO</api> 
     <props>${basedir}/datanucleus.properties</props> 
     <verbose>true</verbose> 
     <enhancerName>ASM</enhancerName> 
    </configuration> 
    <executions> 
     <execution> 
      <phase>process-classes</phase> 
      <goals> 
       <goal>enhance</goal> 
      </goals> 
     </execution> 
    </executions> 
    <dependencies> 
     <dependency> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>datanucleus-core</artifactId> 
      <version>3.1.3</version> 
     </dependency>      
    </dependencies> 
</plugin> 

И усилитель будет работать! Поэтому разница в том, что Google использовал <artifactId>datanucleus-api-jdo</artifactId> , который мне не нужен, и, конечно же, он не отменил выбор версии datanucleus-core, которую следует использовать. Также обратите внимание, что плагин был переименован из maven-datanucleus-plugin в datanucleus-maven-plugin, начиная с 3.2.0-m2. Поэтому я также изменил это, чтобы использовать официальный выпуск 3.2.0. Кроме Google описывает использование копии кувшинов, найденных в AppEngine-Java-СДК-1.9.21/Библиотека/Opt/пользователь/DataNucleus/v2, которые являются:

  • ASM-4.0.jar
  • datanucleus- апи-СДО-3.1.3.jar
  • DataNucleus-апи-JPA-3.1.3.jar
  • DataNucleus-AppEngine-2.1.2.jar
  • DataNucleus-ядро-3.1.3.jar
  • geronimo-jpa_2.0_spec-1.0.jar
  • СДО-апи-3.0.1.jar JTA-1.1.jar

Но так как я не использую муравей, но Maven я просто должен был добавить это зависимостей в pom.xml, чтобы иметь возможность использовать JDO с DataNucleus с версиями явно поддерживаемых Google:

<dependency> 
    <groupId>javax.jdo</groupId> 
    <artifactId>jdo-api</artifactId> 
    <version>3.0.1</version> 
</dependency> 
<dependency> 
    <groupId>org.datanucleus</groupId> 
    <artifactId>datanucleus-core</artifactId> 
    <version>3.1.3</version> 
    <scope>runtime</scope> 
</dependency> 
<dependency> 
    <groupId>org.datanucleus</groupId> 
    <artifactId>datanucleus-api-jdo</artifactId> 
    <version>3.1.3</version> 
</dependency> 
<dependency> 
    <groupId>com.google.appengine.orm</groupId> 
    <artifactId>datanucleus-appengine</artifactId> 
    <version>2.1.2</version> 
</dependency> 

BTW: Я заметил еще одну ошибку в pom.xml, как это предусмотрено действующим Appengine-каркасном архетипа. Ошибка maven «appengine update» не удалась, потому что appengine-maven-plugin попытался загрузить мое приложение с версией, установленной в 1.9.21. Это, очевидно, версия используемого GAE SDK, а не версия моего приложения. И он терпит неудачу, потому что он нарушает разрешенный формат для идентификаторов версий, разрешенных GAE.Исправление было правильно установить версию в конфигурации плагина, добавив строку <version>${app.version}</version> так:

<plugin> 
    <groupId>com.google.appengine</groupId> 
    <artifactId>appengine-maven-plugin</artifactId> 
    <version>${appengine.version}</version> 
    <configuration> 
     <enableJarClasses>false</enableJarClasses> 
     <!-- Comment in the below snippet to bind to all IPs instead of just localhost --> 
     <!-- address>0.0.0.0</address> 
     <port>8080</port --> 
     <!-- Comment in the below snippet to enable local debugging with a remote debugger 
     like those included with Eclipse or IntelliJ --> 
     <!-- jvmFlags> 
      <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag> 
     </jvmFlags --> 
     <version>${app.version}</version> 
    </configuration> 
</plugin> 

Удачи!

0

У меня есть проект строительства должным образом, будучи в состоянии генерировать метаклассами и запустить байткодом энхансер. Но это SBT, а не Maven.

В случае, если вы заинтересованы, пожалуйста, посмотрите на http://github.com/frgomes/poc-scala-datanucleus