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

标签 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 构建成功执行了对 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] --------------------

但是当我尝试启动我的开发服务器时,它失败并出现下一个错误:

[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 类)。

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

最佳答案

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

关于java - 无法读取候选组件类: file [%path%/TestEntity.类];嵌套异常是 java.lang.ArrayIndexOutOfBoundsException: 130,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23975966/

相关文章:

java - 最佳实践 : how to set config file at runtime for tests

java - 自定义服务器错误代码 springMVC 和 tomcat

java - 异常后更新 Camel 交换体并继续路线

python - 如何返回GoogleAPI搜索结果的距离?

java - 滑动时的Android Scrollable Tabs + Swipe状态

java - 神经网络错误趋势

java - Spring Java Config期间的加载顺序

java - 在 Spring 中,如何获取其凭据不属于当前 http 请求一部分的当前用户?

django - 如何在 Google App Engine 灵活部署步骤中运行 Django 迁移?

python - 当我在云端硬盘中创建快捷方式时,它的 mimetype 为 'application/octet-stream',即使我指定了 '' application/vnd.google-apps.drive-sdk''