Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found

I updated gradle version from 4.10.1 to 5.2.1, then this error occured.

> Configure project :
deleteFilesWithType Start
deleteFilesWithType End

> Task :initJpaModelgenSourcesDir
> Task :compileJpaModelgen FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJpaModelgen'.
> Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

2 actionable tasks: 2 executed
Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found

build.gradle is like below:

plugins {
  id 'at.comm_unity.gradle.plugins.jpamodelgen' version '1.1.4'
  id 'idea'
  id 'io.franzbecker.gradle-lombok' version '1.14'
  id 'io.spring.dependency-management' version '1.0.6.RELEASE'
  id 'java'
  id "org.flywaydb.flyway" version "5.2.4"
  id 'org.springframework.boot' version '2.1.2.RELEASE'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {

configurations {
  compile.exclude module: 'slf4j-nop'

dependencyManagement {
  imports {
    mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.483'

dependencies {
  compile group: 'com.amazonaws', name: 'aws-java-sdk-sns'
  compile group: 'com.amazonaws', name: 'aws-java-sdk-s3'
  compile group: 'com.auth0', name: 'java-jwt', version: '3.4.1'
  compile group: '', name: 'icu4j', version: '63.1'
  compile group: 'commons-io', name: 'commons-io', version: '2.6'
  compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'
  compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
  compile group: 'org.apache.commons', name: 'commons-text', version: '1.6'
  compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.6'
  compile group: 'org.codehaus.janino', name: 'janino', version: '3.0.11'
  compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor'
  compile group: 'org.springframework.boot', name: 'spring-boot-devtools'
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis'
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-security'
  compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
  compile group: 'redis.clients', name: 'jedis', version: '2.10.1'

  testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'

jpaModelgen {
  library = 'org.hibernate:hibernate-jpamodelgen:5.4.0.Final'
  jpaModelgenSourcesDir = 'src/main/java'

task deleteJpaFilesWithType (type : Delete) {
  println 'deleteFilesWithType Start'
  setDelete file('src/main/java/xxx/xxx/entity').listFiles().findAll{'')}
  println 'deleteFilesWithType End'

bootJar {
  manifest {
    attributes 'Start-Class': ''

  baseName = 'xxx'
  version = '0.0.1-SNAPSHOT'

bootRun {
  systemProperties as Map<String, ?>

  if (project.hasProperty('args')) {
    args project.args.split('\\s+' as Closure)

flyway {
  driver = 'com.mysql.cj.jdbc.Driver'
  url = 'jdbc:mysql://xxx:3306/xxx'
  user = 'xxx'
  password = 'xxx'

Does anyone have some ideas?

Using Gradle >= 5, you can get rid of additional plugins for JPA meta model generation (like at.comm_unity.gradle.plugins.jpamodelgen is one fo those). Key is to use the new annotationProcessor configuration.

Have a look at this article on Stackoverflow.

As an additional hint, rather than configuring the JavaCompile task (as it is mentioned in the first answer), we are specifying the following in our builds (excerpt):

	// Directory for generated main Java soures.
	generatedMainJava = "${buildDir}/generated/main/java"

	// Add generated sources directory. generatedMainJava

	options.compilerArgs += ['-AaddGenerationDate=true'] // Specific to Hibernate JPA meta model generation processor.
	options.annotationProcessorGeneratedSourcesDirectory = file(generatedMainJava)

Thank you for your support.
I can generate JPA meta model.

Hi, when I use annotationProcessor "org.hibernate:hibernate-jpamodelgen" like your setup I got a weird behavior:

  • Metamodel files is correctly generated under "${buildDir}/generated/main/java"
  • Other metamodel files are also generated under "${buildDir}/classes/java/main/.../entity" but seem has different semantic. Noticeably is that the date="2019-04-09T16:54:02.476+0700" is not generated.
    So I think something messes with my processor. Could you give me a hint to debug?

Seems that you still have two processors running during your build. Which one (perhaps a plugin?) and when, I don’t know. You need to check your build scripts.

I’m with the same task to upgrade gradle 4 to 5 and also the jpamodelgen behaviour.

Should I maintain both:

dependencies {
implementation ‘org.hibernate:hibernate-jpamodelgen’


or only annotationProcessor?

With your code @twwwt I’m getting this error when build:

Task :compileJava
Note: Hibernate JPA 2 Static-Metamodel Generator 5.3.7.Final
An exception has occurred in the compiler (1.8.0_202-release). Please file a bug against the Java compiler via the Java bug reporting page ( after checking the Bug Database ( for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.IllegalStateException: endPosTable already set

using the path: “src/main/java/jpamodelgen”

Thanks in advance :slight_smile:

If you only want to use the annotation processor it is clearly no implementation dependency. You should therefore remove implementation 'org.hibernate:hibernate-jpamodelgen'.

1 Like

I’m using Gradle Buildship Plugin 3.0 on a OpenJdk 11 project under Eclipse. I can’t generate metamodels. This is my build.gradle

buildscript {
    repositories {
    dependencies {

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
    baseName = 'petmenu'
    version =  '0.1.0'

repositories {

sourceCompatibility = 11
targetCompatibility = 11

dependencies {

    compile 'org.springframework.boot:spring-boot-starter-data-jpa'

    implementation 'org.mariadb.jdbc:mariadb-java-client'

} += "${buildDir}/generated"

compileJava {
  options.annotationProcessorGeneratedSourcesDirectory = file("${buildDir}/generated")

Can you tell me what’s the problem?
I would even know if there’s a real-time support channel, like an irc or gitter room.
Thanks in advance.

Ok. Solved.
The build.gradle I posted is correct.
I had a problem of basic understanding of gradle (I thought launching a SpringApplication build from Eclipse would always launch gradle tasks too. Wrong!).
Another problem was that I got installed two versions of jdk on my system, and the old one conflicted with gradle

Could not target platform: ‘Java SE 11’ using tool chain: ‘JDK 10 (1.10)’.