-
1. Re: Location of persistence.xml inside a .war file?
jaikiran May 19, 2010 7:34 AM (in response to stwhit)This might help http://community.jboss.org/wiki/EJB31inAS600M2. Check the section titled "Deployment of EJBs through a .war file"
Post edited: I read only the first half of your question. Your real question is not about EJBs but about where to place the persistence.xml file. You can place that file in WEB-INF/classes folder and package the JPA classes in the WEB-INF/classes folder too.
-
2. Re: Location of persistence.xml inside a .war file?
stwhit May 19, 2010 8:09 AM (in response to jaikiran)Hmmm.... I believe that's what I'm doing, but it doesn't seem to be working.
$ jar tf dist/offerrepository.war
META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/org/
WEB-INF/classes/org/myorg/
WEB-INF/classes/org/myorg/offerrepository/
WEB-INF/classes/org/myorg/offerrepository/ejb/
WEB-INF/classes/org/myorg/offerrepository/jpa/
WEB-INF/classes/org/myorg/offerrepository/web/
WEB-INF/classes/org/myorg/offerrepository/ejb/OfferRepositoryBean.class
WEB-INF/classes/org/myorg/offerrepository/jpa/Offer$Gender.class
WEB-INF/classes/org/myorg/offerrepository/jpa/Offer.class
WEB-INF/classes/org/myorg/offerrepository/web/SearchServlet.class
WEB-INF/classes/persistence.xml
WEB-INF/web.xmlMy EJB injects an EntityManager as such:
@PersistenceContext(unitName = "OfferRepository")
private EntityManager entityManager;My persistence.xml contains this:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="OfferRepository" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/OfferRepositoryDS</jta-data-source>
<class>org.myorg.offerrepository.jpa.Offer</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
</persistence>And when I deploy to JBoss, I receive this error message:
DEPLOYMENTS IN ERROR:
Deployment "vfs:///D:/jboss-6.0.0.20100429-M3/server/default/deploy/offerrepository.war" is in error due to the following reason(s): java.lang.IllegalArgumentException: Can't find a persistence unit named 'OfferRepository' in AbstractVFSDeploymentContext@32823696{vfs:///D:/jboss-6.0.0.20100429-M3/server/default/deploy/offerrepository.war}Any idea what I'm doing wrong? Thanks for the help.
-
3. Re: Location of persistence.xml inside a .war file?
jaikiran Jun 2, 2010 9:16 AM (in response to stwhit)Sorry, forgot about this thread. Were you able to fix this? If not, can you please attach a sample application here, which reproduces this problem. Although I haven't checked, I would expect that we have a testcase for this kind of deployments.
-
4. Re: Location of persistence.xml inside a .war file?
saltnlight5 Jun 2, 2010 3:22 PM (in response to stwhit)2 of 2 people found this helpfulHave you tried placing it like this?
WEB-INF/classes/META-INF/persistence.xml
-
5. Re: Location of persistence.xml inside a .war file?
stwhit Jun 14, 2010 10:12 AM (in response to saltnlight5)That worked. Thanks!
-
6. Re: Location of persistence.xml inside a .war file?
manan007 May 4, 2014 6:53 PM (in response to saltnlight5)Thanks a lot .
Spent 2 hours figuring it out.