-->
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.  [ 9 posts ] 
Author Message
 Post subject: exception setting property value with CGLIB
PostPosted: Wed Jun 02, 2004 2:56 pm 
Beginner
Beginner

Joined: Mon Jan 12, 2004 3:39 pm
Posts: 23
Hi,


I'm having problems when HIbernate tries to load a set.

The property Hibernate can't load is a String Object.

I get this error:
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of fenaseg.rns.bo.ItemSinistroVeiculo.setStFraude
at fenaseg.rns.action.veiculo.CadSinistroAction.consultar(CadSinistroAction.java:154)
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.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at quality.qi.web.action.BasicAction.execute(BasicAction.java:147)
at fenaseg.rns.action.comum.BasicAction.execute(BasicAction.java:94)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Caused by: quality.qi.persistence.PersistenceManagerException: net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of fenaseg.rns.bo.ItemSinistroVeiculo.setStFraude
at quality.qi.persistence.hibernate.HibernatePersistenceManager.find(HibernatePersistenceManager.java:180)
at quality.qi.persistence.hibernate.HibernatePersistenceManager.find(HibernatePersistenceManager.java:157)
at fenaseg.rns.dao.EventoSinistroApoliceDAO.findByChassi(EventoSinistroApoliceDAO.java:39)
at fenaseg.rns.bs.CadastroEventoSinistroApolice.findByChassi(CadastroEventoSinistroApolice.java:86)
at fenaseg.rns.action.veiculo.CadSinistroAction.consultar(CadSinistroAction.java:72)
... 24 more
Caused by: net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of fenaseg.rns.bo.ItemSinistroVeiculo.setStFraude
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:216)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2137)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:239)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:909)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:884)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:80)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3133)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:331)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3007)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:137)
at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
at net.sf.hibernate.loader.Loader.list(Loader.java:940)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:833)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1475)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at quality.qi.persistence.hibernate.HibernatePersistenceManager.find(HibernatePersistenceManager.java:175)
... 28 more
Caused by: net.sf.cglib.beans.BulkBeanException
at fenaseg.rns.bo.ItemSinistroVeiculo$$BulkBeanByCGLIB$$8e2c988f.setPropertyValues(<generated>)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:211)
... 45 more
Caused by: java.lang.ClassCastException
... 47 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 6:12 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
set hibernate.cglib.use_reflection_optimizer=false for more info

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 1:01 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I think you will not get more info without optimizer, it says
setter of fenaseg.rns.bo.ItemSinistroVeiculo.setStFraude is mapped to a wrong type, just fix it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 9:22 am 
Beginner
Beginner

Joined: Mon Jan 12, 2004 3:39 pm
Posts: 23
The property is mapped as String
Code:
    <property
        name="stFraude"
        type="java.lang.String"
        column="ST_FRAUDE"
        length="3"
        not-null="true"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="ST_FRAUDE"
            length="3"
        </meta>   
    </property> 


and is a VARCHAR2(2) in Oracle
Code:
Name                           Type         Nullable
ST_FRAUDE                  VARCHAR2(2)  Y   


And I already added use_reflection_optimizer=false
Code:
<property name="cglib.use_reflection_optimizer">false</property>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 9:43 am 
Beginner
Beginner

Joined: Mon Jan 12, 2004 3:39 pm
Posts: 23
This error onlu occours when running the web appl. The test cases all turn out fine


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 1:16 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
But it is very strange if you are sure, you have single mapping file in classpath, code in "<generated>" is something like this:

Quote:
void setPropertyValues( Object bean, Object [] properties ){

int index = 0;
ItemSinistroVeiculo itemSinistroVeiculo = (ItemSinistroVeiculo)bean;
try{

itemSinistroVeiculo.setStFraude((String)properties[0]);
index ++;

}catch(Exception e){
throw new BulkBeanException( e, index );
}

}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 2:18 pm 
Beginner
Beginner

Joined: Mon Jan 12, 2004 3:39 pm
Posts: 23
Is there anyone I can debug this piece of code? That's probably where the problem is since I have a ClassCastException. What I'd like to know is what is the type Hibernate is trying to cast my property to since every configuration file have the same type as the database.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 2:42 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
vsanta wrote:
Is there anyone I can debug this piece of code? That's probably where the problem is since I have a ClassCastException. What I'd like to know is what is the type Hibernate is trying to cast my property to since every configuration file have the same type as the database.

You can try to attach remote debugger from IDE or use old good "System.out.println()" (It will be better to debug without optimizer, set cglib.use_reflection_optimizer=false as *System* property in server startup script or put "Hibernate.properties" file to classpath ).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 03, 2004 4:32 pm 
Beginner
Beginner

Joined: Mon Jan 12, 2004 3:39 pm
Posts: 23
I just found out what was wrong.

Our database data was imported from a mainframe and some of them have characters that can't be read as any type at all .

Thanks for your help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.