3

我收到以下错误:

Caused by: org.hibernate.HibernateException: CGLIB Enhancement failed: sk.statistics.isis.conceptsvocab.jpa.entities.VocabDomain
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:119)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.getProxy(CGLIBProxyFactory.java:72)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:402)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3483)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:298)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:219)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.EntityType.resolve(EntityType.java:412)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at sk.statistics.isis.conceptsvocab.adminmodule.services.impl.SubdomainsServiceImpl.getAllSubdomainLocalizationNamesForSpecificLocalization(SubdomainsServiceImpl.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy31.getAllSubdomainLocalizationNamesForSpecificLocalization(Unknown Source)
at sk.statistics.isis.conceptsvocab.adminmodule.ui.SubdomainsList.initContent(SubdomainsList.java:210)
at sk.statistics.isis.conceptsvocab.adminmodule.mainWindow.MainPanel.selectWindowToDisplay(MainPanel.java:63)
at sk.statistics.isis.conceptsvocab.adminmodule.mainWindow.MainPanel.access$0(MainPanel.java:50)
at sk.statistics.isis.conceptsvocab.adminmodule.mainWindow.MainPanel$MainPanelListener.valueChange(MainPanel.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
... 26 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.repackage.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:616)
at org.hibernate.repackage.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:609)
at org.hibernate.repackage.cglib.proxy.Enhancer.registerCallbacks(Enhancer.java:578)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyInstance(CGLIBLazyInitializer.java:129)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:116)
... 69 more

Vocab域名列表:

/**
* The persistent class for the VOCAB_DOMAINS database table.
* 
*/
@Entity
@Table(name="VOCAB_DOMAINS")
public class VocabDomain implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = 202977208021067034L;
private Long domainid;
private Long optlockversion;
private Set<VocabDomainsLoc> vocabDomainsLocs;
private Set<VocabSubdomain> vocabSubdomains;

public VocabDomain() {
}


@Id
@SequenceGenerator(name="VOCAB_DOMAINS_DOMAINID_GENERATOR", sequenceName="SEQ_DOMAIN_ID")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="VOCAB_DOMAINS_DOMAINID_GENERATOR")    
public Long getDomainid() {
    return this.domainid;
}

public void setDomainid(Long domainid) {
    this.domainid = domainid;
}

@Version
public Long getOptlockversion() {
    return this.optlockversion;
}

public void setOptlockversion(Long optlockversion) {
    this.optlockversion = optlockversion;
}


//bi-directional many-to-one association to VocabDomainsLoc
@OneToMany(mappedBy="vocabDomain",fetch=FetchType.LAZY) 
public Set<VocabDomainsLoc> getVocabDomainsLocs() {
    return this.vocabDomainsLocs;
}

public void setVocabDomainsLocs(Set<VocabDomainsLoc> vocabDomainsLocs) {
    this.vocabDomainsLocs = vocabDomainsLocs;
}


//bi-directional many-to-one association to VocabSubdomain
@OneToMany(mappedBy="vocabDomain",fetch=FetchType.LAZY)
public Set<VocabSubdomain> getVocabSubdomains() {
    return this.vocabSubdomains;
}

public void setVocabSubdomains(Set<VocabSubdomain> vocabSubdomains) {
    this.vocabSubdomains = vocabSubdomains;
}

@Override
public boolean equals(Object other) {
    if (this == other) {
        return true;
    }
    if (!(other instanceof VocabDomain)) {
        return false;
    }
    if (this.getDomainid() == null) {
        return false;
    }       
    VocabDomain castOther = (VocabDomain) other;
    if (castOther.getDomainid() == null) {
        return false;
    }
    return this.getDomainid().equals(castOther.getDomainid());

}

@Override
public int hashCode() {
    final int prime = 211;
    int hash = 223;
    hash = hash * prime + (this.getDomainid() != null ?     this.getDomainid().hashCode() : 1);
    return hash;
}       
}

执行此命令期间代码失败: Query q = sessionFactory.getCurrentSession().createQuery("SELECT vsd FROM VocabSubdomain vsd LEFT JOIN vsd.vocabSubdomainsLocs"); 列表 vsdl = q.list();


我在 pom.xml 中的依赖项

<spring.version>3.1.1.RELEASE</spring.version>
<hibernate.version>3.4.0.GA</hibernate.version>


<dependencies>

<dependency>
    <!-- na poradi zalezi -->
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-jcl</artifactId>
    <version>1.6.1</version>
</dependency>


<dependency>        
      <groupId>sk.statistics.isis.conceptsvocab.jpa</groupId>
      <artifactId>ConceptsVocabJpa</artifactId>
      <version>0.0.1-SNAPSHOT</version>
</dependency>

    <!-- Spring dependencies -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-acl</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>${spring.version}</version>
    </dependency>   

    <!--  Vaadin dependencies -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <!--  J2EE dependencies -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
    <!-- Portlet dependencies -->       
    <dependency>
        <groupId>javax.portlet</groupId>
        <artifactId>portlet-api</artifactId>
        <version>2.0</version>
        <scope>${portal.scope}</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.portals.bridges</groupId>
        <artifactId>portals-bridges-common</artifactId>
        <version>2.0</version>
    </dependency>   
    <!-- Ldap configuration start -->
    <dependency>
        <groupId>com.sun</groupId>
        <artifactId>ldapbp</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core</artifactId>
        <version>1.3.1.RELEASE</version>
    </dependency>
    <!-- Ldap configuration end -->         
    <!-- Hibernate configuration -->
    <dependency>
      <artifactId>jta</artifactId>
      <groupId>javax.transaction</groupId>
      <version>1.1</version>
      <scope>${websphere.scope}</scope>
      <!--  TODO: pre profil na websphere tu treba dat provided -->
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-annotations</artifactId>
      <version>${hibernate.version}</version>
      <!--  vynechaj jta transakcny management, websphere ma vlastny -->
      <exclusions>
          <exclusion>
              <artifactId>jta</artifactId>
              <groupId>javax.transaction</groupId>
          </exclusion>
          <exclusion>
              <groupId>xml-apis</groupId>
              <artifactId>xml-apis</artifactId>
          </exclusion>
      </exclusions>
    </dependency>
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>${spring.version}</version>
   </dependency>        
   <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-cglib-repack</artifactId>
      <version>2.1_3</version>
    </dependency>
    <dependency>
      <groupId>cglib</groupId>
      <artifactId>cglib</artifactId>
      <version>2.2.2</version>
    </dependency>   
    <!-- Slf4j over commons logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.6</version>
        <type>jar</type>
    </dependency>           
    <!-- 
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.6.6</version>
        <type>jar</type>
    </dependency>           
<dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>1.6.6</version>
    </dependency>
    --> 
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
</dependency>

</dependencies>  
4

1 回答 1

2

问题是由于 hibernate-cglib-repack 造成的。如果您删除该依赖项,它应该可以工作。

背景:在 hibernate 的一个版本中,他们决定将 cglib 类重新打包到 org.hibernate 包下。忽略更改以处理对编码为字符串的类名的引用。因此,一旦将休眠代码升级为使用 2.2 版本的 cglib,就不需要更改,因此它被恢复了。

与此问题相关的休眠错误。

https://hibernate.onjira.com/browse/HHH-3504

https://hibernate.onjira.com/browse/HHH-2875

相关摘录

计划是不再使用重新打包的 cglib,并在它已经发布后迁移到 2.2。事实上,这已经由 Scott 在 SVN 中完成了:HHH-3832

不幸的是,当我们进行此更改时,我们没有太多选择。那时我们已经等待 cglib 2.2 发布一年多了,但我们多次尝试联系他们都没有得到任何回应。我说的是一年多没有发布,而不是 beta、crs、nada。我没有意识到 Enhancer 中的琴弦。我认为阴影插件应该将类的 FQN 处理为字符串。猜不着 在这一点上,考虑到 cglib 2.2 已经过时了,最好继续将它用于 Hibernate 3.5 而不是重新打包。对于 3.3,我们将需要继续使用重新打包,除非 cglib 2.1 和 2.2 是字节码兼容的(我不理解它们)。我将调查这是否已经在阴影插件中得到解决,或者其他选项可能是什么。还, http://anonsvn.jboss.org/repos/hibernate/cglib/那么,谁会自愿看看如何让 cglib 2.2 与 hibernate 一起工作?

于 2012-09-09T16:59:47.507 回答