FilerException when building Java EE 6 Project

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. com.mycompany.foo.PojoOne_ and com.mycompany.bar.PojoOne_ instead of just com.mycompany.PojoOne_.

Source


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.


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:

<exclude-unlisted-classes>true</exclude-unlisted-classes>

to the web.xml file for that persistence unit.


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

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

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

entity1.prod
entity1.dev