Monthly Archives: May 2009

JPA annotated classes in archive


I had  this problem where I created a number of JPA annotated classes in side a jar file. Without listing these in my application persistence.xml these JPA annotated classes are not detected. I tried adding orm.xml and persistence.xml to META-INF directory in the jar file, but then my Webapp persistence.xml wasn’t loaded.

Eventually I ended up removing persistence.xml and orm.xml from the jar file and adding the JPA annotated classes in the jar file to my Webapp persistence.xml. It worked, but Eclipse JPA claims it can’t resolve the class and shows an error on persistence.xml.


The Webapp works fine so in the meantime I won’t bother about the Eclipse error, but obviously one day I will be Googling for a solution.