IllegalStateException in Hibernate metamodel generation with maven

主宰稳场 提交于 2019-11-29 14:06:00

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>

Same issue faced with gradle build as well. If you have previously metamodel classes available @ source-generate(please check the build.gradle file to check the path where your model classes being generated), this issue will come when run gradle build.

Solution : Delete the existing model classes and run gradle build. It should workout.

This bug is fixed in the meantime. You should use maven compiler plugin 3.6 or higher:

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

I have just found another cause of this error: an old version of the maven-processor-plugin (2.1.0 in my case). I got the 'endPosTable already set' even when running mvn clean package. Upgrading the maven-processor-plugin and hibernate-jpamodelgen to the latest versions helped.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!