Hibernate-jpamodelgen [ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type

Hi all
I’ve been trying to make this work, it did the first time, but then I got this error

[INFO] --- maven-processor-plugin:4.5:process (process) @ hospitalService ---
[INFO] diagnostic: Note: Hibernate JPA 2 Static-Metamodel Generator 5.6.10.Final
[WARNING] diagnostic: warning: Unable to parse persistence.xml: Unable to perform unmarshalling at line number 0 and column 0. Message: null
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.Consultorio_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.EspecialidadPreferencia_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.Ala_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.Hospital_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.TratamientoFlujoPaso_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.NotificacionMensajeRol_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.EntidadDocumento_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.SalaEsperaEspecialidad_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.Estudio_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.PreferenciaAtencionDisparo_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.SalaEspera_
[ERROR] diagnostic: error: Problem with Filer: Attempt to recreate a file for type py.com.skytel.hospital.model.Tratamiento_

there is no relevant info besides that

no matter which versions I try, ends the same way

the pom

    <properties>
        <java.version>11</java.version>
        <hibernate.version>5.4.1.Final</hibernate.version>

        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <failOnMissingWebXml>false</failOnMissingWebXml>

        <maven.test.skip>true</maven.test.skip>
    </properties>

with procesor version 3.x

           <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>${java.version}</release>
                    <compilerArgument>-proc:none</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>3.3.3</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <processors>
                                <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                            </processors>
                            <fork>true</fork>
                            <releaseVersion>11</releaseVersion>
                            <options>
                                <debug>false</debug>
                            </options>
                            <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-jpamodelgen</artifactId>
                        <version>5.6.10.Final</version>
                    </dependency>
                </dependencies>
            </plugin>
 

with procesor version 4.x

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>${java.version}</release>
                    <compilerArgument>-proc:none</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>4.5</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <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>5.6.10.Final</version>
                    </dependency>
                </dependencies>
            </plugin>

any suggestions ?

Have you tried using an output directory in target yet? The Filer API in annotation processors does not allow to overwrite existing files, so this is why you get the error. If you use the target folder, the files will be removed before generating resources usually. Either way, you’d have to clean the folder you want to put files into before re-generating them.

overwriting existing files would be a killer feature :grinning:
ok, will do a work around and change the destination folder

thanks

You should ask the OpenJDK community for this “killer feature” as this is simply how javac works.

1 Like