Hi. I'm trying to have OpenJPA run with my J2EE app. I don't want to have to list all of the involved classes in my persistence.xml I have run the enhancer on all the entity objects as part of compiling things over.
If I use this persistence.xml: <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> <persistence-unit name="Snap"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <non-jta-data-source>snap_db_jpa</non-jta-data-source> </persistence-unit> </persistence> I get this exception on trying to run a named query: java.lang.RuntimeException: <openjpa-2.1.1-r422266:1148538 fatal user error> org.apache.openjpa.persistence.ArgumentException: There is no query with the name "E_Device.GET_ALL" defined for any of the known persistent classes: null. xxx.SnapStore.createDeviceList(SnapStore.java:1186) xxx.SnapStore.service(SnapStore.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) *root cause* <openjpa-2.1.1-r422266:1148538 fatal user error> org.apache.openjpa.persistence.ArgumentException: There is no query with the name "E_Device.GET_ALL" defined for any of the known persistent classes: null. org.apache.openjpa.meta.MetaDataRepository.getQueryMetaDataInternal(MetaDataRepository.java:1938) org.apache.openjpa.meta.MetaDataRepository.getQueryMetaData(MetaDataRepository.java:1919) org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:1023) org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:1016) xxx.SnapStore.createDeviceList(SnapStore.java:1176) xxx.SnapStore.service(SnapStore.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) That's because the query is in a NamedQuery annotation of an entity. If I add '<class>xxx.E_Device</class>' to the persistence.xml, it finds that query. I couldn't find a way to ask OpenJPA to scan the current class path, but I'm not even sure it's possible in J2EE app, for app classes. Thanks, Pawel.