2012-09-07 84 views
3

我真的得到以下錯誤:CGLIB增強失敗:參數類型不匹配

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 

VocabDomain列表:此命令的執行期間

/** 
* 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; 
}  
} 

代碼失敗: 查詢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> 
+0

?這很可能是版本衝突。 – gkamal

+0

Cglib重新包裝2.1_3和休眠3.4.0 GA – user1655265

+0

我想你需要擺脫hibernate-cglib重新包裝 - https://forum.hibernate.org/viewtopic.php?f=1&t=994331 – gkamal

回答

2

的問題是依賴由於休眠-CGLIB的重新包裝。如果你刪除該依賴關係,它應該工作。

背景: 在一個hibernate版本中,他們決定將cglib類重新打包到org.hibernate包下。忽略該更改以處理對以字符串編碼的類名稱的引用。所以它被恢復了,因爲一旦hibernate代碼升級到使用2.2版本的cglib,就不需要進行更改。

休眠與此問題有關的錯誤。

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

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

有關摘錄

The plan is to no longer use the repackaging of cglib and to migrate to 2.2 now that it has been released. In fact this is already done by Scott in SVN : HHH-3832

Unfortunately we did not have much of a choice when we made this change. We had been waiting on cglib 2.2 release for well over a year at that point and had gotten no response from our multiple attempts to contact them. And I am talking about over a year of no releases at all, not betas, crs, nada. I did not realize about the strings inside Enhancer. I thought the shade plugin was supposed to handle FQN of classes as strings. Guess not At this point, considering cglib 2.2 is out its probably best to go ahead and use it for Hibernate 3.5 instead of the repack. For 3.3 we will need to continue to use the repack unless cglib 2.1 and 2.2 are bytecode compatible (which they are not to my understanding). I'll investigate whether that has been addresses in the shade plugn yet, or what other options might be. Also, there is a project we use to produce the shaded repack: http://anonsvn.jboss.org/repos/hibernate/cglib/ So, whose gonna volunteer to see what it takes to get cglib 2.2 working with hibernate?

您正在使用什麼版本的Hibernate和CGLIB的
+0

我''也通過註釋將休眠改爲3.5.6-Final。 使用cglib 2.2.2。它現在工作。 – user1655265