org.hibernate.MappingException迁移到JBoss 7

时间:2015-06-04 03:54:25

标签: jpa jboss jboss7.x jpa-2.0

我正在将两个应用程序从JBoss 5.1 EAP迁移到JBoss AS 7.1.1。应用程序有自己的数据库,但包含许多具有共同布局的表。这些公用表的带注释实体类在common.jar中定义,它位于{jboss.server.home.url} / lib目录中,实体类在应用程序EAR的persistence.xml中定义。其他特定于应用程序的实体类打包在EAR内的EJB JAR中。

由于JBoss7中不再存在{jboss.server.home.url} / lib目录目录,我想在EAR的lib目录中打包common.jar,以便EAR现在看起来像这样:

app.ear

/META-INF/
    persistence.xml
    MANIFEST.MF
    application.xml
/lib/
    common.jar
app-ejb.jar
app.war

persistence.xml中的持久性单元定义为

<persistence-unit name="ca" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:jboss/datasources/appDS</jta-data-source>
    <class>com.mycorp.entity.CommonTable1</class>
    <class>com.mycorp.entity.CommonTable2</class>
    <class>com.mycorp.app.entity.AppSpecificTable</class>
    <jar-file>common.jar</jar-file>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
        <property name="hibernate.hbm2ddl.auto" value="validate" />
        <property name="hibernate.show_sql" value="false" />
        <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/appEntityManagerFactory"/>
    </properties>
</persistence-unit>

但是,当我部署应用程序时,JPA在common.jar中找不到带注释的实体类:

18:17:02,903 TRACE [org.jboss.as.jpa] getClassesInJar url=/content/common.jar annotations=[interface javax.persistence.MappedSuperclass, interface javax.persistence.Entity, interface javax.persistence.Embeddable]
18:17:02,909 TRACE [org.jboss.as.jpa] No classes to scan for annotations in jar 'vfs:/content/common.jar' (jars with classes '[vfs:/content/app.ear/lib/common.jar/, vfs:/content/app.ear/app-ejb.jar/]')
18:17:02,910 TRACE [org.jboss.as.jpa] getPackagesInJar url=/content/common.jar annotations=[]
18:17:02,910 TRACE [org.jboss.as.jpa] No classes to scan for annotations in jar 'vfs:/content/common.jar' (jars with classes '[vfs:/content/app.ear/lib/common.jar/, vfs:/content/app.ear/app-ejb.jar/]')

后来导致这个“org.hibernate.MappingException:Unknown entity:com.mycorp.entity.CommonTable1”异常。

我认为这是某种类加载器问题,但我不知道如何让JPA看到我的实体类。

0 个答案:

没有答案