I have this scenario in a EAR application which have the following structure:

  • Project
    • data
    • ear
    • entity
      • META-INF
        • persistence.xml
    • business
    • web

At the entity folder there is all the entity classes and a persistence.xml with the hibernate.hbm2ddl.auto property setted to create. When I deploy the jar about entity the database is generated but when I deploy the ear he isn't. Please somebody can let me know why this is happening and some way to solve it?

有帮助吗?

解决方案

In your EAR project you must have a META-INF/application.xml file, that includes the entity jar file:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
  <display-name>MY_ear</display-name>
  <module>
    <ejb>ENTITY.jar</ejb><!--change the name accordingly-->
  </module>
</application>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top