使用maven生成Hibernate元模型的IllegalStateException [英] IllegalStateException in Hibernate metamodel generation with maven

查看:139
本文介绍了使用maven生成Hibernate元模型的IllegalStateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用hibernate-jpamodelgen使用maven生成元模型类。



当我运行 mvn clean package 时,它可以正常工作,没有任何问题。但是,如果我第二次运行 mvn软件包(不清除),则会收到以下异常:

 编译器发生异常(1.8.0_51)。请在Bug Parade上检查重复项目后,请在Java Developer Connection(http://java.sun.com/webapps/bugreport)上提交错误。在您的报告中包含您的计划和以下诊断。谢谢。 
java.lang.IllegalStateException:endPosTable已经在com.sun.tools.javac.util.DiagnosticSource.setEndPosTable中设置了
(DiagnosticSource.java:136)
在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)
在com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1187)
。在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)
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:125)
at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
在org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:825)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
。在组织.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
。在组织.apache.maven.lifecycle.internal.Lifec ycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
。在org.apache.maven.lifecycle.internal。 builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
位于org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
位于org.apache.maven。 DefaultMaven.doExecute(DefaultMaven.java:355)
在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
在org.apache.maven.cli.MavenCli.execute(MavenCli。
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java: 289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java: 415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

环境

  JDK版本:1.8.0_51 
Maven版本:3.3
Hibernate版本:4.3.7.Final

摘自我的pom.xml :

 <依赖关系> 
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-jpamodelgen< / artifactId>
< version> 4.3.7.Final< / version>
< scope>提供< / scope>
< /依赖关系>


解决方案

找到答案!...



这是 3.2 & maven-compiler-plugin 的3.3版本。

当我运行 mvn软件包第二次,以前生成的源目录会添加到生成源阶段之前的源路径,并导致此解析器异常



切换回Maven-compiler-plugin 修复的旧版本(< )。
$ b

请注意,增量编译 3.0 & maven-compiler-plugin 3.1 版本。所以,我更喜欢切换 2.5.1 版本的maven-compiler-plugin。

 < ;依赖性> 
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.5.1< / version>
< /依赖关系>


I'm using hibernate-jpamodelgen to generate the metamodel classes using maven.

When i run mvn clean package, it works fine without any problem. But if i run the mvn package second time (without clean), I'm getting the following exception :

An exception has occurred in the compiler (1.8.0_51). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade 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)
    at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:125)
    at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:825)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Environment:

JDK version : 1.8.0_51
Maven version : 3.3
Hibernate version : 4.3.7.Final

Snippet from my pom.xml:

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>4.3.7.Final</version>
            <scope>provided</scope>
        </dependency>

解决方案

Found the Answer!...

It's a bug in 3.2 & 3.3 versions of maven-compiler-plugin.

When I run the 'mvn package' second time, the previously generated source directory is added to the source path before the generate-source phase and it causes this parser exception.

Switching back to the older version (<3.2) of maven-compiler-plugin fixes the issue.

Note that the incremental compilation is broken in 3.0 & 3.1 versions of maven-compiler-plugin. So, I prefer to switch the 2.5.1 version of maven-compiler-plugin.

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.5.1</version>
</dependency>

这篇关于使用maven生成Hibernate元模型的IllegalStateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆