读取候选组件类失败:文件[%path%/TestEntity.class];嵌套异常为java.lang.ArrayIndexOutOfBoundsException:130

读取候选组件类失败:文件[%path%/TestEntity.class];嵌套异常为java.lang.ArrayIndexOutOfBoundsException:130,java,spring,google-app-engine,maven,jpa,Java,Spring,Google App Engine,Maven,Jpa,我正在尝试创建一个简单的Google应用程序引擎+Spring+JPA(数据核)工具。在我尝试启动本地开发服务器之前,一切看起来都很好。我的pom配置: <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </depende

我正在尝试创建一个简单的Google应用程序引擎+Spring+JPA(数据核)工具。在我尝试启动本地开发服务器之前,一切看起来都很好。我的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>
我已经反编译了我的增强持久性类TestEntity.class,但在那里找不到任何错误:一切看起来都很好。同样,同一实体也可以很好地处理这个配置:GAE+JPA(数据核)。在这两种情况下,构建输出(见上文)是相同的。因此,我建议将问题缩小到Spring框架(特别是org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor类)


我不知道这和什么有关。我在互联网上找到的答案大多与编译文件中的错误有关,我没有任何错误。

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

自己解决了这个问题。事实证明,我的增强JPA实体类位于Spring扫描的目录中,用于搜索组件。当我将增强的JPA实体类移动到Spring未扫描的单独文件夹中时,一切都开始正常工作。Spring无法处理增强的JPA实体类。
[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] --------------------
[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