2 Replies Latest reply on Sep 19, 2005 3:37 AM by Patrik Meisinger

    EJB3.0 Problem: exception setting property value with CGLIB

    Patrik Meisinger Newbie

      i'm trying to run my RCP client application and receive the following error when accessing my database via jboss (ejb3.0) application server:
      org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of ams.ingres.model.OmOpos.setOmOkopf

      the deployment of my beans is ok.

      the relation of the entities look like this:
      PvStamp(1)<->(*)OmOcros(*)<->(1)OmOkopf(1)<->(*)OmOpos

      the sql joins for the relations are:
      PvStamp.ident = OmOcros.cross_1
      OmOkopf.objekt = OmOcros.objekt
      OmOkopf.objekt = OmOpos.objekt

      the problem occurs when changing the FetchType in OmOkopf.java from
      @OneToMany(targetEntity = ams.ingres.model.OmOpos.class, mappedBy = "omOkopf", fetch = FetchType.LAZY)

      to
      @OneToMany(targetEntity = ams.ingres.model.OmOpos.class, mappedBy = "omOkopf", fetch = FetchType.EAGER)

      PvStamp.java looks like this:

      @Entity (access = AccessType.PROPERTY)
      @Table (name="PV_STAMP")
      public class PvStamp {
       @Id
       @Column(name="ident")
       public Integer getIdent() {
       return ident;
       }
       public void setIdent(Integer ident) {
       this.ident = ident;
       }
      
       @OneToMany (targetEntity=ams.ingres.model.OmOcros.class, mappedBy="pvStamp", fetch=FetchType.EAGER)
       public Collection<OmOcros> getOmOcros() {
       return (Collection<OmOcros>)omOcros;
       }
       public void setOmOcros(Collection<OmOcros> omOcros) {
       this.omOcros = (Collection <OmOcros>) omOcros;
       }
      }
      


      OmOcros.java looks like this:
      @Entity (access = AccessType.PROPERTY)
      @Table (name="OM_OCROS")
      public class OmOcros {
       @Id
       @Column (name="OBJEKT")
       public Integer getObjekt() {
       return objekt;
       }
       public void setObjekt(Integer objekt) {
       this.objekt = objekt;
       }
      
       @ManyToOne (targetEntity=ams.ingres.model.OmOkopf.class, fetch=FetchType.EAGER)
       @JoinColumn(name="objekt", nullable=true)
       public OmOkopf getOmOkopf() {
       return omOkopf;
       }
       public void setOmOkopf(OmOkopf omOkopf) {
       this.omOkopf = omOkopf;
       }
      
       @ManyToOne (targetEntity=ams.ingres.model.PvStamp.class, fetch=FetchType.LAZY)
       @JoinColumn(name="cross_1", nullable=true)
       public PvStamp getPvStamp() {
       return pvStamp;
       }
       public void setPvStamp(PvStamp pvStamp) {
       this.pvStamp = pvStamp;
       }
      }
      
      

      OmOkopf.java looks like this:
      @Entity(access = AccessType.PROPERTY)
      @Table(name = "OM_OKOPF")
      public class OmOkopf {
       @Id
       @Column (name="OBJEKT")
       public Integer getObjekt() {
       return objekt;
       }
      
       public void setObjekt(Integer objekt) {
       this.objekt = objekt;
       }
       @OneToMany(targetEntity = ams.ingres.model.OmOpos.class, mappedBy = "omOkopf", fetch = FetchType.EAGER)
       public Collection<OmOpos> getOmOpos() {
       return (Collection<OmOpos>) omOpos;
       }
      
       public void setOmOpos(Collection<OmOpos> omOpos) {
       this.omOpos = omOpos;
       }
      
       @OneToMany(targetEntity = ams.ingres.model.OmOcros.class, mappedBy = "omOkopf", fetch = FetchType.EAGER)
       public Collection<OmOcros> getOmOcros() {
       return (Collection<OmOcros>) omOcros;
       }
      
       public void setOmOcros(Collection<OmOcros> omOcros) {
       this.omOcros = omOcros;
       }
      }
      

      OmOpos.java looks like this:
      @Entity(access = AccessType.PROPERTY)
      @Table(name = "OM_OPOS")
      public class OmOpos {
       @Id
       @Column(name = "IDENT")
       public Integer getIdent() {
       return ident;
       }
      
       public void setIdent(Integer ident) {
       this.ident = ident;
       }
      
       @ManyToOne(targetEntity = ams.ingres.model.OmOpos.class, fetch = FetchType.LAZY)
       @JoinColumn(name = "objekt", nullable = true)
       public OmOkopf getOmOkopf() {
       return omOkopf;
       }
       public void setOmOkopf(OmOkopf omOkopf) {
       this.omOkopf = omOkopf;
       }
      }
      


      full stack trace of the exception that occurs:
      14:21:54,763 INFO [STDOUT] org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of ams.ingres.model.OmOpos.setOmOkopf
       at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:217)
       at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:187)
       at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2945)
       at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:115)
       at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:791)
       at org.hibernate.loader.Loader.doQuery(Loader.java:689)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:221)
       at org.hibernate.loader.Loader.loadCollection(Loader.java:1699)
       at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
       at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:490)
       at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
       at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1437)
       at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:313)
       at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:775)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:226)
       at org.hibernate.loader.Loader.doList(Loader.java:1858)
       at org.hibernate.loader.Loader.list(Loader.java:1842)
       at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:407)
       at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:273)
       at org.hibernate.impl.SessionImpl.list(SessionImpl.java:850)
       at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
       at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:41)
       at ams.ingres.model.facade.AkteFacade.getAllPvStamp(AkteFacade.java:46)
       at ams.ingres.model.facade.AkteFacade.getAllAkten(AkteFacade.java:81)
       at ams.beans.stateless.AktenBean.getAllAkten(AktenBean.java:29)
       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.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:33)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:93)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:183)
       at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
       at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:325)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:201)
       at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:259)
       at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:313)
       at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:147)
      Caused by: net.sf.cglib.beans.BulkBeanException: ams.ingres.model.OmOpos$$EnhancerByCGLIB$$f7da3c5d
       at ams.ingres.model.OmOpos$$BulkBeanByCGLIB$$59f7f033.setPropertyValues(<generated>)
       at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:214)
       ... 50 more
      Caused by: java.lang.ClassCastException: ams.ingres.model.OmOpos$$EnhancerByCGLIB$$f7da3c5d
       ... 52 more
      


      i'm using eclipse3.1, hibernate 3.1, jboss4.0.3RC1 with ejb3.0, jdk1.5, jbosside1.5M2, hibernatetools 3.1alpha5.

      what could be wrong?. any help is appreciated.

      thanks in advance!
      best regards
      patrik