-->
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.  [ 1 post ] 
Author Message
 Post subject: AbstractMethodError with abstract classes
PostPosted: Wed Jul 20, 2005 6:29 am 
Beginner
Beginner

Joined: Fri Mar 12, 2004 1:12 pm
Posts: 25
Location: Minsk, Belarus
I try to migrate existing project from Hibernate 2.1.8 to 3.0.5 and I have one problem with subclassing. I beleive that is bug but if I am wrong please point me documentation.

I have parent abstract class
Code:
class abstract Parent{
  abstract getField1();
  abstract getField2();
}

and set of derived classes

Code:
class First extends Parent{
  getField1() {return somevalue};
  getField2() {return somevalue};
}

And corresponding mapping class

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class  table="XXX" name="com.Parent">
    <id unsaved-value="null" name="id">
      <generator class="native"/>
    </id>
    <discriminator column="type"/>
    <subclass name="com.First"/>
    <subclass name="com.Second"/>
  </class>
</hibernate-mapping>


I am not using Field1 and Field2 for mapping. It is just methods that I want to override in derived classes. But on start of application I got AbstractMethodException. See stack trace below. After some researching I found solution: add to class tag lazy="false" attribute.
Does it right solution??

Exception:

Code:
3516 [http-8080-Processor25] ERROR org.hibernate.proxy.BasicLazyInitializer  - CGLIB Enhancement failed: de.kesselweb.mydiablo.data.beans.Character
net.sf.cglib.core.CodeGenerationException: java.lang.AbstractMethodError-->de.kesselweb.mydiablo.data.beans.Character.getInitialStrength()I
        at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
        at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
        at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216)
        at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:606)
        at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:532)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
        at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:373)
        at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:281)
        at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:640)
        at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:94)
        at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:42)
        at org.hibernate.tuple.PojoTuplizer.buildProxyFactory(PojoTuplizer.java:144)
        at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:83)
        at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54)
        at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47)
        at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218)
        at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
        at org.nanocontainer.persistence.hibernate.SessionFactoryDelegator.<init>(SessionFactoryDelegator.java:42)
        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.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:128)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:154)
        at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:56)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:182)
        at org.picocontainer.defaults.DecoratingComponentAdapter.getComponentInstance(DecoratingComponentAdapter.java:43)
        at org.picocontainer.defaults.CachingComponentAdapter.getComponentInstance(CachingComponentAdapter.java:38)
        at org.picocontainer.defaults.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:341)
        at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:324)
        at org.picocontainer.alternatives.ImmutablePicoContainer.getComponentInstance(ImmutablePicoContainer.java:40)
        at org.picocontainer.defaults.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:347)
        at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:324)
        at org.picocontainer.alternatives.ImmutablePicoContainer.getComponentInstance(ImmutablePicoContainer.java:40)
        at org.picocontainer.defaults.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:347)
        at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:324)
        at org.picocontainer.defaults.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:80)
        at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:117)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:191)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:151)
        at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:56)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:182)
        at org.picocontainer.defaults.DecoratingComponentAdapter.getComponentInstance(DecoratingComponentAdapter.java:43)
        at org.picocontainer.defaults.CachingComponentAdapter.getComponentInstance(CachingComponentAdapter.java:38)
        at org.picocontainer.defaults.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:341)
        at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:324)
        at org.picocontainer.defaults.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:80)
        at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:117)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:191)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:151)
        at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:56)
        at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:182)
        at org.picocontainer.defaults.DecoratingComponentAdapter.getComponentInstance(DecoratingComponentAdapter.java:43)
        at org.picocontainer.defaults.CachingComponentAdapter.getComponentInstance(CachingComponentAdapter.java:38)
        at org.picocontainer.defaults.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:341)
        at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstancesOfType(DefaultPicoContainer.java:300)
        at org.picocontainer.defaults.DefaultLifecycleManager.start(DefaultLifecycleManager.java:65)
        at org.picocontainer.defaults.DefaultPicoContainer.start(DefaultPicoContainer.java:389)
        at org.nanocontainer.integrationkit.LifecycleContainerBuilder.autoStart(LifecycleContainerBuilder.java:52)
        at org.nanocontainer.integrationkit.LifecycleContainerBuilder.buildContainer(LifecycleContainerBuilder.java:45)
        at org.nanocontainer.nanowar.ServletRequestContainerLauncher.startContainer(ServletRequestContainerLauncher.java:41)
        at org.nanocontainer.nanowar.ServletRequestContainerFilter.doFilter(ServletRequestContainerFilter.java:43)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.AbstractMethodError: de.kesselweb.mydiablo.data.beans.Character.getInitialStrength()I
        at de.kesselweb.mydiablo.data.beans.Character$$EnhancerByCGLIB$$cbf7b529.CGLIB$getInitialStrength$22(<generated>)
        at de.kesselweb.mydiablo.data.beans.Character$$EnhancerByCGLIB$$cbf7b529$$FastClassByCGLIB$$eff3cee5.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:167)
        at org.hibernate.proxy.CGLIBLazyInitializer$1.intercept(CGLIBLazyInitializer.java:174)
        at de.kesselweb.mydiablo.data.beans.Character$$EnhancerByCGLIB$$cbf7b529.getInitialStrength(<generated>)
        at de.kesselweb.mydiablo.data.beans.Character.<init>(Character.java:57)
        at de.kesselweb.mydiablo.data.beans.Character$$EnhancerByCGLIB$$cbf7b529.<init>(<generated>)
        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 net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
        ... 80 more

_________________
In order to understand recursion one must first understand recursion


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

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.