The moose likes Object Relational Mapping and the fly likes java.lang.IllegalArgumentException: Unknown entity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.lang.IllegalArgumentException: Unknown entity" Watch "java.lang.IllegalArgumentException: Unknown entity" New topic

java.lang.IllegalArgumentException: Unknown entity

Christoph Schmidl

Joined: Sep 21, 2010
Posts: 3
hey there

I don't know if it's the right place to ask, if not... feel free to move the thread ;)
well, I`m using seam 2 with hibernate, ejb3, richfaces, ibm websphere and Rational Software Architect as my IDE (based on eclipse) and I tried to test my persistence entity packages, which are all located in an extra project.
I've created a new project with testng, which just should contain test-classes, who are referencing the entity classes in the persistence project, initiate them and run the tests... but it seems, it's not that easy. I added the imports in the test-classes to the entities in the persistence-project and all seems normal, no errors. I wrote a test, which just initiates the persistence entity, persist it to the oracle db, reads them out trough the entitiy-manager by using "find()" and remove the entity again from the db.
And here comes the error: at the point, where the entitiy-manager tries to persist the entity, I get the following error:

It seems like the application finds the class, otherwise the import wouldn't have worked, but when it tries to persist, it doesn't have the mapping, doesn't have the class in the runtime classpath or whatever. Maybe it's because there is a persistence.xml in the entity-package and an extra persistence.xml in the testng-project?

here's the persistence.xml from the testng-proect. I also tried to publish the class by adding the "<class>"-tag to the xml-file, but it cannot resolve the name? weird...

and the persistence.xml from the entity-project:

any suggestions? ;)

Christoph Schmidl

Joined: Sep 21, 2010
Posts: 3
i changed some project-dependencies and added the required class by using the "class"-tag in the persistence.xml. it works that way, my tests run without any errors, but isn't there a more sophisticated way available for adding entities? I don't want to add hundreds of classes to the xml-file just because I want to reach them through my tests
Christoph Schmidl

Joined: Sep 21, 2010
Posts: 3
anyone? there has to be a way to scan a path for entities....
Consider Paul's rocket mass heater.
subject: java.lang.IllegalArgumentException: Unknown entity
Similar Threads
Could not resolve a persistence unit corresponding to the persistence-context-ref-name
A question about "persistence.xml" by Weblogic
Jboss Error
Problem with Mapping between 1 bit column and boolean field
EclipseLink1.1 inserts no data..