On Tue, Jun 3, 2008 at 11:52 AM, Phani Madgula <[EMAIL PROTECTED]> wrote:
> I was able to inject EntityManager in a servlet class by placing > META-INF/persistence.xml in WEB-INF/classes. Only when > META-INF/peristence.xml is placed in WEB-INF/classes does the web > application is able to read the persistence.xml (application > classloader is able to find it). I couldn't figure it out myself either why META-INF in the webapp root was not searched for persistence.xml's, but that's how it's in webapps (I guess it's because the classloader for a webapp doesn't include / in its classpath). It'll change in Java EE 6 (I couldn't resist mentioning it ;-)) Anyway, I think you'd be better off placing your entities (or better the classes that constitute the model) to a separate project and include jar file only. It makes your model "technology clean" and no ties with JPA will ever exist in the model. persistence.xml and orm.xml would go to WEB-INF/classes/META-INF or any other jar file in WEB-INF/lib. It could be that the jar file with orm.xml and persistence.xml files would contain these files only so it's possible to replace just the jar file to change the jpa configuration. Just a couple of ideas. Jacek -- Jacek Laskowski http://www.JacekLaskowski.pl
