Search code examples
jpaentityeclipselinkillegalargumentexceptionpersistence.xml

Adding new class to persistence.xml throws java.lang.IllegalArgumentException: Object: Restaurants{id=null, name=Subway} is not a known entity type


I created a new entity class, and added it to the persistence.xml file.

<class>xxx.xxx.xxx.xxx.xxx.Restaurants</class>

When trying to build in Maven, I get this error:

Caused by: java.lang.IllegalArgumentException: Object: Restaurants{id=null, name=Subway} is not a known entity type.

How is this caused and how can I solve it? There are no problems with the other entity classes, but just this one.


Solution

  • In some of our applications we use Maven build profiles that use different persistence.xml files for testing, production, etc. http://maven.apache.org/guides/introduction/introduction-to-profiles.html