views:

160

answers:

2

I have a maven-managed project with some modules (with jar package) , each module contains its "persistence.xml" in its META-INF directory.

Another module take responsibilities to package these modules into a war file . But I find no way to "combine" these "persistence.xml" into one file ...

Is it possible ?

Thanks in advanced.

+2  A: 

If you know XSLT, you can write a transform to merge the persistence documents. Maven has a plugin for running XSLT (and validationg XML) - xml-maven-plugin

But do you need to do this? Reading here, and here, for example, states that persistence.xml will be picked up from all jars, not just the webapp war. So you should be able to leave persistence.xml in your library jars and the will be used by the webapp.

mdma
A: 

Another module take responsibilities to package these modules into a war file . But I find no way to "combine" these "persistence.xml" into one file

Why would you like to do this? If you have several JARs that have a persistence.xml, they define very likely different persistence units (A persistence unit defines the set of all classes that are related or grouped by the application and which must be colocated in their mapping to a single database).

Why don't you obtain an EntityManagerFactory for the right persistence unit?

Pascal Thivent
Thank you , because my app server (resin 4.0.7) seems cannot load persistence.xml inside jars , so I want to combine these persistence.xml(s) into one.Well , maybe it's resin's settings , I'll further look into it.
smallufo