无法读取候选组件类:file [%path%/ TestEntity.class];嵌套异常是java.lang.ArrayIndexOutOfBoundsException:130

时间:2014-06-01 01:22:16

标签: java spring google-app-engine maven jpa

我正在尝试创建简单的Google App Engine + Spring + JPA(datanucles)工具。在我尝试启动本地开发服务器之前,一切似乎都很好。我的pom配置:

 <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>  
      <groupId>org.datanucleus</groupId>  
      <artifactId>datanucleus-api-jpa</artifactId>  
      <version>${datanucleus.jpa.version}</version>  
    </dependency>  
    <dependency>  
      <groupId>org.datanucleus</groupId>  
      <artifactId>datanucleus-core</artifactId>  
      <version>${datanucleus.jpa.version}</version>  
    </dependency>  
    <dependency>  
      <groupId>com.google.appengine.orm</groupId>  
      <artifactId>datanucleus-appengine</artifactId>  
      <version>2.1.1</version>  
      <!-- Need to exclude the enhancer since it interfere with the enhancer plugin. -->  
    <!--   <exclusions>  
        <exclusion>  
          <groupId>org.datanucleus</groupId>  
          <artifactId>datanucleus-enhancer</artifactId>  
        </exclusion>  
      </exclusions>
       -->  
    </dependency>  
    <dependency>  
      <groupId>javax.jdo</groupId>  
      <artifactId>jdo-api</artifactId>  
      <version>3.0.1</version>  
    </dependency>  
    <dependency>  
      <groupId>org.apache.geronimo.specs</groupId>  
      <artifactId>geronimo-jpa_2.0_spec</artifactId>  
      <version>1.1</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>
</dependencies>

<build>
    <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory> 

    <plugins>
        <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>org.datanucleus</groupId>  
          <artifactId>maven-datanucleus-plugin</artifactId>  
          <version>${datanucleus.jpa.version}</version>  

          <configuration>  
            <api>JPA</api>  
            <mappingIncludes>io.volat.logger.persistence.entities/*.class</mappingIncludes>  
            <verbose>true</verbose>  
          </configuration>  

          <dependencies>  
            <dependency>  
              <groupId>org.datanucleus</groupId>  
              <artifactId>datanucleus-core</artifactId>  
              <version>${datanucleus.jpa.version}</version>  
            </dependency>  
          </dependencies>  

          <executions>  
            <execution>     
              <phase>compile</phase>  
              <goals>  
                <goal>enhance</goal>  
              </goals>  
            </execution>  
          </executions>  
        </plugin>

    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.datanucleus
                                    </groupId>
                                    <artifactId>
                                        maven-datanucleus-plugin
                                    </artifactId>
                                    <versionRange>
                                        [${datanucleus.jpa.version},)
                                    </versionRange>
                                    <goals>
                                        <goal>enhance</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

Maven build使用下一个输出成功执行TestEntity.class的增强:

[INFO] --- maven-datanucleus-plugin:3.1.1:enhance (default) @ logger-war ---
Downloading: http://www.datanucleus.org/downloads/maven2/org/datanucleus/datanucleus-                    enhancer/maven-metadata.xml
Downloading: http://www.datanucleus.org/downloads/maven2/javax/jdo/jdo-api/maven-metadata.xml
Downloading: http://www.datanucleus.org/downloads/maven2/org/ow2/asm/asm/maven-metadata.xml
[INFO] DataNucleus Enhancer (version 3.1.1) : Enhancement of classes
DataNucleus Enhancer completed with success for 1 classes. Timings : input=342 ms, enhance=122 ms, total=464 ms. Consult the log for full details

[ERROR] --------------------
[ERROR]  Standard error from the DataNucleus tool + org.datanucleus.enhancer.DataNucleusEnhancer :
[ERROR] --------------------
[ERROR] May 31, 2014 5:13:37 PM org.datanucleus.enhancer.DataNucleusEnhancer <init>
INFO: DataNucleus Enhancer for API "JPA"
May 31, 2014 5:13:37 PM org.datanucleus.enhancer.DataNucleusEnhancer main
INFO: DataNucleus Enhancer (version 3.1.1) : Enhancement of classes
May 31, 2014 5:13:37 PM org.datanucleus.metadata.MetaDataManager loadFiles
WARNING: Metadata file -enhancerName not found in CLASSPATH
May 31, 2014 5:13:37 PM org.datanucleus.metadata.MetaDataManager loadFiles
WARNING: Metadata file ASM not found in CLASSPATH
May 31, 2014 5:13:37 PM org.datanucleus.enhancer.AbstractClassEnhancer save
INFO: Writing class file "/Users/abarysevich/backend/logger/logger-war/target/logger-war-1.0-    SNAPSHOT/WEB-INF/classes/io/volat/logger/persistence/entities/TestEntity.class" with enhanced     definition
May 31, 2014 5:13:38 PM org.datanucleus.enhancer.DataNucleusEnhancer addMessage
INFO: DataNucleus Enhancer completed with success for 1 classes. Timings : input=342 ms, enhance=122 ms, total=464 ms. Consult the log for full details

[ERROR] --------------------

但是当我尝试启动我的devserver时,它会因下一个错误而失败:

[INFO] SEVERE: Context initialization failed
[INFO] org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/abarysevich/backend/logger/logger-ear/target/logger-ear-1.0-SNAPSHOT/logger-war-1.0-SNAPSHOT.war/WEB-INF/classes/io/volat/logger/persistence/entities/TestEntity.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 130

我已经反编译了我的增强型持久化类TestEntity.class但在那里找不到任何错误:一切对我来说都很好。同样的实体也适用于此配置:GAE + JPA(数据核心)。在这两种情况下,构建输出(见上文)都是相同的。所以,我建议将问题缩小到Spring框架(特别是org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor类)。

我不知道它有什么关系。我在互联网上找到的答案主要是关于编译文件中的错误我没有。

1 个答案:

答案 0 :(得分:1)

原始海报找到的解决方案是将其增强的JPA实体类移动到单独的文件夹中。在搜索组件时确保它们位于Spring扫描目录之外。