0

I know there has been similar questions, but none answers to my problem. I am using JBoss 7.1.1 and Hibernate 2.0, the entities contained in external archives yet reported in the <jar-file> </jar-file> are not autodetected unless I enter manually one by one these entities between the tag <class> </class> is my persitence.xml file:

<persistence version="2.0"
   xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
 <persistence-unit name="alooh-security">
        <jta-data-source>java:jboss/datasources/alooh-security</jta-data-source>
        <jar-file>alooh-security-model-1.0.0-SNAPSHOT.jar</jar-file>
         <properties>
        <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/alooh-security"/>
        <property name="hibernate.connection.username" value="root"/>
        <property name="hibernate.connection.password" value="123456"/>
            <!-- Properties for Hibernate (default provider for JBoss AS) -->
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="false" />
            <property name="hibernate.archive.autodetection" value="class, hbm" />
        </properties>
   </persistence-unit>
</persistence>

No @Entity annotated class in the archive alooh-security-model-1.0.0-SNAPSHOT.jar are detected by JPA. I am obliged to enter manually one by one all entities in alooh-security-model-1.0.0-SNAPSHOT.jar between the tag <class> </ class> and it's really painful!
Is there a solution?
Thank you

Belin
  • 343
  • 1
  • 5
  • 17
  • did you deploy your app using an ear ? did you get a log about not finding your jar file ? – fla Mar 17 '16 at 15:07
  • No. My app is deployed using a war. My entites are contained in a jar library – Belin Mar 18 '16 at 08:45
  • Did you take a look to this [thread](http://stackoverflow.com/questions/4433341/what-is-the-right-path-to-refer-a-jar-file-in-jpa-persistence-xml-in-a-web-app) ? – fla Mar 18 '16 at 09:58
  • also consider using absolute path althought i think this is a worse solution than listing entity classes – fla Mar 18 '16 at 10:00
  • 1
    Ok i've seen where is the problem when looking log files. Rather than use alooh-security-model-1.0.0-SNAPSHOT.jar ,we must use lib/alooh-security-model-1.0.0-SNAPSHOT.jar the problem is now solved – Belin Mar 18 '16 at 10:14

1 Answers1

0

Ok i've seen where is the problem when looking log files. Rather than use <jar-file>alooh-security-model-1.0.0-SNAPSHOT.jar</jar-file> ,we must use

<jar-file>lib/alooh-security-model-1.0.0-SNAPSHOT.jar</jar-file>

the problem is now solved

Belin
  • 343
  • 1
  • 5
  • 17