Hibernate on my app server (JBoss 4.2.3) is not picking up my entities so it seems like the persistence.xml is not in the correct place. If I put a persistence.xml file in META-INF directory of each jar file with a different unit name hibernate picks up and deploys all my entities. But I want only one unit name (persistence unit) for all my entities even though they are in a different jar.
Billy Newman wrote:Hibernate on my app server (JBoss 4.2.3) is not picking up my entities so it seems like the persistence.xml is not in the correct place.
You need to specify the entity jar files in the persistence.xml. The persistence.xml xsd allows for multiple jar-file elements where you can specify those jar files. The other details can be found here
For those of you familiar with older versions of the spec, there is no .par file anymore. Entities are placed in a EJB-JAR .jar file or a .jar file all their own. You must also define a persistence.xml file that resides in the META-INF folder of the .jar file. Here's an example of a persistence.xml file.
4.3. EAR and WAR files
JBoss 4.0.x does not support the Java EE 5 EAR format. So, if you want to deploy a standalone persistence archive, you must list it within application.xml as an ejb module.
For WAR files, JBoss 4.0.x does not yet support deploying a persistence archive with WEB-INF/lib as required by the spec.
Although it does say Jboss 4.0.x does not support Java EE Ear format, but since I cannot get this to work my guess is that JBoss 4.2.x also does not support it.
Oh well I guess at least I know this is a JBoss limitation.
I am some what sure that packaging in the .ear/META-INF was supported in AS 4.2.x. The jar-file entry would point to the correct jars. But it's been a very long time now since i have played with 4.x versions. If it's feasible, move to the latest stable 5.1.0 of AS which is fully compliant with the spec.