Reputation: 579
in the jhipster's build based on gradle, the hot-reload functionality provided by spring-boot-devtools fails because of hibernate annotation-processor. During the auto-make/build compilation, the compiler throws error "Problem with Filer: Attempt to recreate a file for type com.example.accessingdatarest.domain.User_" which aborts the re-compilation. The problem can be reproduced in a much smaller scale project by using the "Accessing JPA Data with REST" spring sample project and then adding spring-boot devtools and hibernate annotation-process to the build-gradle file as shown below:
dependencies {
developmentOnly('org.springframework.boot:spring-boot-devtools')
annotationProcessor('org.hibernate.orm:hibernate-jpamodelgen')
Error message thrown by the compiler is (for Intellij, this shows up in the "auto-build" window):
Information:Errors occurred while compiling module 'accessing-data-rest.main'
Information:javac 21.0.4 was used to compile java sources
Error:java: Problem with Filer: Attempt to recreate a file for type
com.example.accessingdatarest.domain.User_
Note1: the project will still automatically restart but code-changes are not recompiled
Note2: if I remove the hibernate annotation-processor (from the spring sample project), the hot-reload works as expected.
Has anyone found a solution to this issue ?
Side-Note1: I'm a bit confused for why no-one else reported the same issue.
Side-Note2: I have the same problem on different OS (windows & ubuntu) and different jdks (17 & 21)
[ UPDATE ]
After playing around further with the smaller spring sample project (described above), I believe that I've managed to make the issue fully repeatable.
The problem seems to be with Intellij auto-make and registry value "compiler.automake.postpone.when.idle.less.than" = 3000 (by default).
If you delete the build folder and then start the app just/right after (within <3secs), that will result in the auto-build happening AFTER the manual build (triggered by the manual start). Hence the compilation linked to the auto-make complains about the generated source-file already existing. After that step, the hot-reload stops working (because after a failed incremental build, Gradle tries to switch to a full build ?).
As far as the smaller Spring sample is concerned, just deleting the build folder seems to solve the issue but unfortunately that doesn't seem to be the case for the bigger jhipster project: once the compiler error happens, it keeps coming back for each new build.
[ UPDATE2 ]
As of now, the only work-around I've found is to move the classes generated by the hibernate annotation-processor to the source-code folder and to disable/comment that annotation-processor in the build.gradle file.
Upvotes: 0
Views: 67