FilerException when building Java EE 6 Project

I have a Java EE 6 Project in Netbeans 7 which runs fine when I compile and start it in the IDE. However, when I clean and build the project, I am getting a

java.lang.RuntimeException: javax.annotation.processing.FilerException: Attempt to recreate a file for type {myclass}

(where myclass is always a JPA entity class).

Which entity class it is changes if I change something in the code.

I have no clue what might cause this error - can anyone provide an idea what to look at.

The only extra lib I am using is Velocity.

Update: I am using two persistence units on the same database, one 'normal' one and one non transactional one. The non-transactional one I use for logging things to the database; with a commit after each insert of a log event.

When I change that and only use the one 'normal' PU, the project compiles fine. Could it be that the two PUs interfere with some optimization done by eclipselink?

Here is the beginning of the stack trace:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.RuntimeException: javax.annotation.processing.FilerException: Attempt to recreate a file for type de.guj.contenthub.ftdts.entity.AgofEntry_
    at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(

Having two persistence units using the same Entity class did seem to be the problem.

In my case I had one unit for querying data and the other for authentication. The one for authentication does not need to know about my Entity classes, so in Netbeans I had to uncheck the "Include All Entity Classes in "MyWebServiceProject" Module". Or add:


to the web.xml file for that persistence unit.

FilerException when building Java EE 6 Project, I have a Java EE 6 Project in Netbeans 7 which runs fine when I compile and start it in the IDE. However, when I clean and build the project, I am getting a. 42. Java EE Security: Advanced Topics. Part VIII Java EE Supporting Technologies. 43. Introduction to Java EE Supporting Technologies. 44. Transactions. 45. Resources and Resource Adapters. 46. The Resource Adapter Example. 47. Java Message Service Concepts. 48. Java Message Service Examples. 49. Bean Validation: Advanced Topics. 50. Using Java

I got this solved by setting

<property name="eclipselink.canonicalmodel.subpackage" value="foobar"/>

for each persistence unit in persistence.xml. The value has to be unique for each unit. The classes are then generated into different packages, eg. and instead of just com.mycompany.PojoOne_.


java ee - maven beginner, I have a Java EE 6 Project in Netbeans 7 which runs fine when I compile and start it in the IDE. FilerException : Attempt to recreate a file for type { myclass }. Preface This tutorial is a guide to developing enterprise applications for the Java Platform, Enterprise Edition 6 (Java EE 6) using GlassFish Server Open Source Edition. Oracle GlassFish Server, a Java EE compatible application server, is based on GlassFish Server Open Source Edition, the leading open-source and open-community platform for

The answser is to make this in the persistence.xml file;

<persistence-unit name="prod_PU">
    <property name="eclipselink.canonicalmodel.subpackage" value="prod"/>
<persistence-unit name="dev_PU">
      <property name="eclipselink.canonicalmodel.subpackage" value="dev"/>

For example, the packages for the entity1 will be generated as :

Java EE 6プロジェクトをビルドするときのFilerException, on project XXXXXX: Fatal error compiling: java.lang. netbeans-FilerException when building Java EE 6 Project-Stack Overflow Right click on your project, select run as -> maven build in goals, write: mvn -X clean install. Found problem in your pom.xml ${}/endorsed ${} is a variable which you used but haven't defined. you can do it like this

It seems, the problem is that I use one and the same entity class in two different persistence units. I am not sure whether this forbidden by JPA in general or is only a problem with eclipselink.

One 'solution' I found then is to duplicate my entity class. Not nice, but works for now.

More answers still welcome.

Java EE & Java Web Learning Trail, A collection of tutorials, articles, and demos on creating web applications in POM Project (Part 1 of 6); YouTube: API and Service OSGi Bundle (Part 2 of 6) JSP + Servlets + EJB: Java EE 6 & GlassFish 3 using NetBeans 6.9 (Part 1 of 5)  Click the Finish button to create the Java EE 6 dynamic web project. To add ObjectDB/JPA support to the project, drag the objectdb.jar file from the file system and drop it in the WebContent/WEB-INF/lib node in the Eclipse Project Explorer: You should now have an Eclipse Java EE 6 project with ObjectDB/JPA support.

I'm having the same issue, and have diagnosed it a bit to the point that I have an ugly workaround that is not ideal.

I have two persistence units in my persistence.xml: one for testing and one for the actual production build.

The reason I have that is because if I use the preferred method of putting another persistence.xml under the src/tests/resources/META-INF folder, the tests fail because the generated classes get put in a the target/generated-sources/test-annotations folder and don't end up in the right place in the classpath once they compile.

The issue is that if both have the "exclude-unlisted-classes" set to true, the javac compiler tries to recreate the annotation classes during the compiler:compile and of course fails on the second PU because the classes have already been created.

So to get this to work, I set the "exclude-unlisted-classes" to false for one of the PU's, which gets me the generated meta classes, and the tests fail (because the PU doesn't include the required entities).

I then flip the flag back to true, and run the build again. Since the classes have already been compiled, the compile:compile doesn't run, and the tests can succeed.

Workaround was proc:none to the javac compiler args as described here:

                    <verbose />

JavacProcessingEnvironment.doProcessing() has thrown a , Compiling error JEE 6 project with Criteria. on Stack Overflow by Djan Yu Lee, 3 years ago. javax.annotation.processing.FilerException: Attempt to recreate a file  Note that we are going to use Enterprise JavaBeans 3.1 specification which corresponds to Java EE 6 platform. JDeveloper will create the project and automatically will start Entities From Tables Wizard . 5. In Entities From Tables Wizard leave settings in steps 2 and 3 by default and move to the step 4 where you need to define DB connection

User bilelovitch, · 15 · sql query to return differences between two tables · · 5 · FilerException when building Java EE 6 Project. The full Java EE profile is required if the application uses a remote interface. Choose File > New Project (Ctrl-Shift-N; ⌘-Shift-N on Mac) from the main menu. Select Web Application from the Java Web category and click Next. Type SimpleEE6App for the project name and set the project location.

In this tutorial, you create and build a Java Platform, Enterprise Edition (Java EE) application using Maven. You learn how to apply JavaServer Faces 2.1 (JSF 2.1) to support a web application by using the NetBeans integrated development environment (IDE).

Eclipse IDE for java EE (I’m using eclipse kepler) Apache tomcat 6. Download zip file; For installing eclipse and apache tomcat 6, simply extract them to some suitable folder. Configure Apache Tomcat with Eclipse: Open eclipse. It will ask for some workspace. Select the folder you want to use as workspace. As you’ve donwloaded eclipse IDE

  • Thanks, your answer showed me the right direction: set exclude-unlisted-classes to true and add the entities manually for each persistenceUnit
  • it solved the issue for me
  • Welcome to SO! It doesn't make much sense to answer such an old question which in fact has many answers and marked answered as well. Also you need to read this section of Help center.