问题
I'm currently creating my entities and DAO with Hibernate Tools and reverse engineering. My config is Eclipse Indigo, JBoss AS7, Hibernate Tools 3.4 and Hibernate 4. The problem is when I try to deploy my .jar to JBoss AS7 I get this :
http://pastebin.com/1hvHBM7z
And more precisely :
Can't find a persistence unit named null in deployment "businessLayer.jar"
Now, I searched about this issue and it suggests I should have a persistence.xml file under META-INF. The thing is, the generation didn't do anything regarding this file (it even disabled its generation when I checked annotations and not JPA during the console config) and when I look at the samples, I'm unsure what to specify... Another question : from what I understand, this file is necessary for the EntityManager, but why would I need this if all the required informations is already in my hibernate.cfg.xml (because I mean, the two files look kinda similar...) ?
回答1:
Actually it seems you need to have the persistence xml, which get rid of the issue above. Then you're likely to have a new exception : JDBC Driver not found etc. The problem came from JBoss 7 and Postgre9 for me. More information here (last post).
来源:https://stackoverflow.com/questions/11512555/cant-find-persistence-unit-and-reverse-engineering-tools