File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.lang.IllegalArgumentException: Unknown entity" Watch "java.lang.IllegalArgumentException: Unknown entity" New topic
Author

java.lang.IllegalArgumentException: Unknown entity

Christoph Schmidl
Greenhorn

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? ;)

SCJA, SCJP
Christoph Schmidl
Greenhorn

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
Greenhorn

Joined: Sep 21, 2010
Posts: 3
anyone? there has to be a way to scan a path for entities....
 
Don't get me started about those stupid light bulbs.
 
subject: java.lang.IllegalArgumentException: Unknown entity