java.lang.IllegalStateException:endPosTable已设置

问题描述 投票:14回答:5

试图建立一个alexa(亚马逊:回声)技能组合。同时,尝试使用这种经验作为通过匕首2依赖注入的学习测试平台。但是,使用maven-2 cmd构建包:

mvn assembly:assembly -DdescriptorId=jar-with-dependencies package'. 

生成具有完整依赖项的zip jar会产生以下异常跟踪:

[INFO] ------------------------------------------------------------------------
[INFO] Building Echo Device Client 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ echo-device-client ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/apil.tamang/Dropbox/Git/echo-device-client/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ echo-device-client ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 46 source files to /Users/apil.tamang/Dropbox/Git/echo-device-client/target/classes
An exception has occurred in the compiler (1.8.0_60). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.IllegalStateException: endPosTable already set
        at com.sun.tools.javac.util.DiagnosticSource.setEndPosTable(DiagnosticSource.java:136)
        at com.sun.tools.javac.util.Log.setEndPosTable(Log.java:350)
        at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:667)
        at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.<init>(JavacProcessingEnvironment.java:892)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.next(JavacProcessingEnvironment.java:921)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1187)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)

初始编译很好,所有测试都运行并成功执行。我觉得在“连接”事物向南的依赖关系时。请在构建期间查看this file以查看控制台输出。

我的问题是,如果尝试使用不同的方式生成依赖项是值得的。我不太了解maven的目的。是否有可以使用的补丁或其他东西?你认为甚至可以提出一个解决方法吗?我希望能够继续使用dagger 2框架来构建这个项目。

compiler-errors java-8 maven-2 dagger-2
5个回答
13
投票

错误报告JDK-8067747中描述了该问题:

(作者Jan Lahoda)

据我所知,这个bug存在两个方面:

  1. 它碰到异常的javac错误。我正在研究这个问题,但请注意,当修复此问题时,javac将不会编译输入,它会从Filer抛出一个适当的异常(见下文)。
  2. 似乎是一个maven bug:当项目使用“clean install”编译时,注释处理器将生成一个源文件到“target / generated-sources / annotations”。增量编译完成后,此生成的文件将作为输入传递给javac,注释处理器将尝试再次生成它,这是不允许的。

这意味着当maven bug被修复时,javac用不适当的异常报告问题的错误变得无关紧要。但是,考虑到Maven 2的生命终结的实际日期,我怀疑你可以期待找到它的修复或补丁。


3
投票

正如this issue中所解释的,解决方法是禁用useIncrementalCompilation

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>

    <configuration>
        <useIncrementalCompilation>false</useIncrementalCompilation>
    </configuration>
</plugin>

0
投票

我不确定这是否有帮助。对于我的情况,我遇到了与open-jdk 8u91相同的问题,我安装了oracle-jdk,我可以在mvn clean compile之后运行该项目。问题是我必须在JDK之间切换每次运行并再次使用maven构建它。

编辑:经过两天的努力,我发现它是mavenjdk不匹配的结果。我的IDE使用maven 3.0.5作为捆绑的maven。

解决方案:在IDE中,您应该将maven主目录从bundled maven更改为当前版本,例如/usr/share/maven。 (对我来说当前版本是3.3.9)


0
投票

我遇到了与Maven和JDK 1.8.0_121构建和测试的项目相同的错误。在原始配置中,项目首先通过mvn clean清理,然后使用mvn install -projectSpecificParameters构建,最后使用单独的mvn install -otherProjectSpecificParameters进行测试。此配置导致问题中提到的错误。

在更改阶段的顺序(首次测试然后构建)并在构建命令中添加clean目标以在测试之后清除构建状态之后,错误不再可再现。


0
投票

在我的情况下,这是在使用maven-processor-plugin插件生成JPA元数据文件时发生的。我只使用特殊的Maven配置文件生成了一次文件,并将它们添加到源文件夹中。

如错误报告中所述,当再次编译现有文件时会发生这种情况。解决方案是在执行maven-processor-plugin之前删除已编译的文件。例如。:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <executions>
        <execution>
            <id>clean-jpa-model</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>clean</goal>
            </goals>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>
                            ${project.basedir}/src/main/java
                        </directory>
                        <includes>
                            <include>**/model/*_.java</include>
                        </includes>
                    </fileset>
                </filesets>
                <excludeDefaultDirectories>true</excludeDefaultDirectories>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <executions>
        <!--precompilation to find annotations and classed needed by the maven processor plugin for hibernate-jpamodelgen-->
        <execution>
            <id>compile-maven-processor</id>
            <goals>
                <goal>compile</goal>
            </goals>
            <phase>process-sources</phase>
            <configuration>
                <showDeprecation>false</showDeprecation>
                <showWarnings>false</showWarnings>
                <includes>
                    <include>**/model/*.java</include>
                </includes>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>
    <version>3.3.3</version>
    <executions>
        <execution>
            <id>generate-jpa-model</id>
            <goals>
                <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <includes>
                    <include>**/model/*.java</include>
                </includes>
                <processors> 
                    <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                </processors>
                    <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
            </configuration>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>${hibernate.version}</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
</plugin>    
© www.soinside.com 2019 - 2024. All rights reserved.