【问题标题】:Load persistence unit with vfsfile (exploded JAR) on JBoss 5.1/Hibernate 3.3.2在 JBoss 5.1/Hibernate 3.3.2 上使用 vfsfile (exploded JAR) 加载持久性单元
【发布时间】:2011-10-05 08:46:39
【问题描述】:

我正在寻求帮助以解决从 JBoss4 迁移到 JBoss5 时出现的问题。 Hibernate 对 VFS 的支持似乎存在问题(在 JBoss5 中引入)。

出于模块化原因,多个工件具有持久性单元 (pu) 声明。 在部署期间,它们都被合并到一个类似于

的声明中
Processing PersistenceUnitInfo [
    name: pu
    persistence provider classname: null
    classloader: org.jboss.web.tomcat.service.WebCtxLoader$ENCLoader@7a74fa
    Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@432f0a33
    excludeUnlistedClasses: false
    JTA datasource: com.xyz.jdbc.datasource.DelegatingDataSource@4546bcba
    Non JTA datasource: com.xyz.jdbc.datasource.DelegatingDataSource@4546bcba
    Transaction type: JTA
    PU root URL: vfszip:/<path>/<jar>/
    Jar files URLs [
        vfsfile:/<path>/<exploded jar>/
        vfsfile:/<path>/<exploded jar>/
        vfsfile:/<path>/<exploded jar>/
        vfszip:/<path>/<jar>/
        vfszip:/<path>/<jar>/
        vfszip:/<path>/<jar>/]
    Managed classes names []
    Mapping files names []
    Properties []

启用调试时,我们可以看到爆炸后的 jar 没有被扫描以查找注释

[org.hibernate.ejb.packaging.AbstractJarVisitor] Searching mapped entities in jar/par: vfsfile:/<path>/<exploded jar>/
[org.hibernate.ejb.packaging.AbstractJarVisitor] Searching mapped entities in jar/par: vfsfile:/<path>/<exploded jar>/

而像预期的那样扫描紧凑的 JAR

[org.hibernate.ejb.packaging.AbstractJarVisitor] Searching mapped entities in jar/par: vfszip:/<path>/<jar>/
[org.hibernate.ejb.packaging.AbstractJarVisitor] Filtering: com.xyz.batch.configuration.internal.impl.JobMetadataDocumentImpl$1$JobList
...

导致查询未找到的实体时出现 QuerySyntaxException

org.hibernate.hql.ast.QuerySyntaxException: <EntityName> is not mapped 

【问题讨论】:

    标签: hibernate jboss5.x vfs persistence-unit


    【解决方案1】:

    根据 Red Hat 支持,无法对已分解的 JAR 进行扫描。 有两种解决方案:

    • 使用 Compact JAR 并按预期进行扫描
    • 使用 Exploded JAR 并在持久化单元中使用 标签声明所有 @Entity。

    【讨论】:

    • Red Hat 承认这是一个错误。预计将在 2011 年 11 月末发布修补程序
    猜你喜欢
    • 2012-12-19
    • 1970-01-01
    • 1970-01-01
    • 2020-05-29
    • 2017-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-16
    相关资源
    最近更新 更多