These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: ClassCastException deploying .sar jboss-3.2.1
PostPosted: Wed Dec 10, 2003 11:53 pm 
Newbie

Joined: Wed Dec 10, 2003 8:40 pm
Posts: 14
Location: Sydney
Hi -

I get the following exception while trying to deploy a sar to jboss

14:39:19,469 INFO [Binder] Mapping class: com.generator.dom.hibernate.Company -> companies
14:39:19,783 INFO [ReflectHelper] reflection optimizer disabled for: com.generator.dom.hibernate.Address, ClassCastException: null
14:39:19,791 ERROR [Configuration] Could not configure datastore from input stream
java.lang.ClassCastException
at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:90)
at net.sf.cglib.reflect.FastClass.create(FastClass.java:72)
at net.sf.hibernate.type.ComponentType.<init>(ComponentType.java:113)
at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:817)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:963)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:321)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1173)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:268)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:291)
at net.sf.hibernate.jmx.HibernateService.buildSessionFactory(HibernateService.java:160)
at net.sf.hibernate.jmx.HibernateService.start(HibernateService.java:131)
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:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:966)
at $Proxy11.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:392)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy5.start(Unknown Source)
at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:640)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:613)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy7.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:458)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:200)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:211)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:190)
14:39:19,807 INFO [HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: Error reading resource: com/generator/dom/hibernate/Company.hbm.xml


Here is the classes

public class Company implements ICompany {

private Long id;
private int version;
private String abn;
private String acn;
private IAddress address;

public void setAddress(IAddress anAddress) {
this.address = anAddress;
}

public IAddress getAddress() {
return this.address;
}

//other getter/setters ommitted
}

public class Address implements IAddress {
//body ommitted
}

here is the meta-data for the company class

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.generator.dom.hibernate.Company" table="companies" discriminator-value="comp" proxy="com.generator.dom.hibernate.Company">
<id name="id" column="companyid" type="long">
<generator class="native"/>
</id>

<version name="version" type="integer"/>

<property name="abn" type="java.lang.String"/>
<property name="acn" type="java.lang.String"/>
<property name="alias" type="java.lang.String" not-null="true"/>
<property name="comments" type="java.lang.String"/>
<property name="website" type="java.lang.String"/>
<property name="name" type="java.lang.String" not-null="true"/>
<property name="status" type="com.generator.dom.hibernate.Status" not-null="true"/>

<component name="address" class="com.generator.dom.hibernate.Address">
<property name="street" type="java.lang.String" not-null="true"/>
<property name="city" type="java.lang.String" not-null="true"/>
<property name="zip" type="java.lang.String" not-null="true"/>
<property name="state" type="com.generator.dom.hibernate.State" not-null="true"/>
<property name="country" type="com.generator.dom.hibernate.Country" not-null="true"/>
</component>

<set name="contacts" inverse="true" lazy="true">
<key column="companyid"/>
<one-to-many class="com.generator.dom.hibernate.Contact"/>
</set>

<set name="projects" inverse="true" lazy="true">
<key column="companyid"/>
<one-to-many class="com.generator.dom.hibernate.Project"/>
</set>

</class>

</hibernate-mapping>

I' ve tried changing the class type in the address component to the interface but I still get the same error. Is this a problem with the component class implementing an interface?

cheers
andy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 7:43 pm 
Beginner
Beginner

Joined: Fri Aug 29, 2003 3:39 pm
Posts: 33
Location: San Francisco, CA
This looks like it has to be some sort of ClassLoading problem. Unfortunately such things are not too uncommon with JBoss and I do not have a solution. Do make sure that there are no other versions of CGLIB in your classpath (for instance Spring and Ibatis both use CGLIB too).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 8:41 pm 
Newbie

Joined: Wed Dec 10, 2003 8:40 pm
Posts: 14
Location: Sydney
herbyderby

Thanks for the reply, you were right I had the spring distribution in my classpath and it uses cglig-asm.jar. Now I am getting the following:

11:34:08,398 INFO [Binder] Mapping class: com.generator.dom.hibernate.Company -> companies
11:34:08,748 INFO [ReflectHelper] reflection optimizer disabled for: com.generator.dom.hibernate.Address, CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
11:34:08,828 ERROR [Configuration] Could not configure datastore from input stream
net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:192)
at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:92)
at net.sf.cglib.reflect.FastClass.create(FastClass.java:74)
at net.sf.hibernate.type.ComponentType.<init>(ComponentType.java:113)
at net.sf.hibernate.cfg.Binder.bindComponent(Binder.java:833)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:978)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:338)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1167)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:245)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:268)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:291)
at net.sf.hibernate.jmx.HibernateService.buildSessionFactory(HibernateService.java:174)
at net.sf.hibernate.jmx.HibernateService.start(HibernateService.java:145)
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:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:966)
at $Proxy11.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:392)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy5.start(Unknown Source)
at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:640)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:613)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy7.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:458)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:200)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:211)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:190)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:373)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:181)
... 44 more
Caused by: java.lang.LinkageError: duplicate class definition: com/generator/dom/hibernate/Address$$FastClassByCGLIB$$52b92f44
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
... 49 more
11:34:08,884 INFO [HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: Error reading resource: com/generator/dom/hibernate/Company.hbm.xml

Still looks like some kind of class loading issue

cheers
andy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 2:11 am 
Newbie

Joined: Wed Dec 10, 2003 8:40 pm
Posts: 14
Location: Sydney
When I deploy hibernate as part of my application instead as a standalone
.sar the codeGenerationException goes away

cheers
andy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 2:21 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
You need to configure deployment, app sar must depend on hibernate sar.
Cglib uses application classloader to define classes, but cache is in hibernate classloader, it will duplicate all classes after redeployment.
It is possible to solve in cglib too (add hibernate.jar classloder system hashcode to class name ), we will think about this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.