Classloader problem when using cobertura instrumented classes in unit tests 
that use Hibernate 3.1
--------------------------------------------------------------------------------------------------

         Key: MOJO-194
         URL: http://jira.codehaus.org/browse/MOJO-194
     Project: Mojo
        Type: Bug

  Components: sandbox  
 Environment: Windows XP Prof, SP2
    Reporter: Ralf Quebbemann


Classloader problem when using cobertura instrumented classes when running unit 
tests using Hibernate 3.1.
Hibernate specifies asm-1.5.3 in its pom which requires the file but cobertura 
specifies asm-2.1 in its pom. 

The problem seems to be that Hibernate cannot load asm-1.5.3 because cobertura 
has already loaded the latest version, which is incompatible. 

The problem is described on the Cobertura FAQ page and they recommend:

"Cobertura does not need ASM in your classpath when running tests. If you're 
seeing classpath conflicts, just make sure the asm jar that comes with 
Cobertura is used only by Cobertura, and only when instrumenting." 

Here is the stacktrace:

ERROR [hibernate.proxy.BasicLazyInitializer.getProxyFactory()] CGLIB
Enhancement failed: com.gargantus.tradingcode.domain.Market
java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
        at
net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)
        at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
        at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
        at
net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
        at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
        at
org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
        at
org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
        at
org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
        at
org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
        at
org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
        at
org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
        at
org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
        at
org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
        at
org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
        at
org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
        at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
        at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
        at
com.gargantus.tradingcode.HibernateUtil.<init>(HibernateUtil.java:74)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
        at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:75)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:670)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:329)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveConstructorArguments(AbstractAutowireCapableBeanFactory.java:706)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:611)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:329)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72)
        at
com.gargantus.tradingcode.SpringComponentFactoryAdaptor.setContext(SpringComponentFactoryAdaptor.java:55)
        at
com.gargantus.tradingcode.SpringComponentFactoryAdaptor.<init>(SpringComponentFactoryAdaptor.java:32)
        at
com.gargantus.tradingcode.ComponentFactory.reinitialise(ComponentFactory.java:156)
        at
com.gargantus.tradingcode.ComponentFactory.initFromCSV(ComponentFactory.java:121)
        at
com.gargantus.tradingcode.ComponentFactory.reinitialise(ComponentFactory.java:105)
        at
com.gargantus.tradingcode.ComponentFactory.initialise(ComponentFactory.java:84)
        at
com.gargantus.testing.util.DbUnitTransactionAwareTestCase.setUp(DbUnitTransactionAwareTestCase.java:125)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        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:585)
        at
org.codehaus.surefire.battery.JUnitBattery.executeJUnit(JUnitBattery.java:246)
        at
org.codehaus.surefire.battery.JUnitBattery.execute(JUnitBattery.java:220)
        at org.codehaus.surefire.Surefire.executeBattery(Surefire.java:204)
        at org.codehaus.surefire.Surefire.run(Surefire.java:153)
        at org.codehaus.surefire.Surefire.run(Surefire.java:77)
        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:585)
        at
org.codehaus.surefire.SurefireBooter.run(SurefireBooter.java:104)
        at
org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:303)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:432)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:530)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:472)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:858)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:729)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:501)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:485)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:455)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:249) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to