-->
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: Spring + Hibernate = exception setting property value
PostPosted: Fri Apr 02, 2004 1:11 pm 
Newbie

Joined: Tue Sep 30, 2003 12:59 pm
Posts: 8
Hi guys,

I'm having a little brain issues on a friday so i might be missing something here and need another set of eyes.

I keep getting this error:

12:05:57,063 INFO TransactionInterceptor:190 - Invoking rollback for transaction on method 'getModel' in class [com.openpeak.service.ModelManager] due to throwable [org.springframework.orm.hibernate.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.openpeak.model.HardwareMetaData.setValueItem; nested exception is net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.openpeak.model.HardwareMetaData.setValueItem]
12:05:57,073 INFO HibernateTransactionManager:347 - Initiating transaction rollback
12:05:57,073 ERROR ModelActionListener:? - DAOException
org.springframework.orm.hibernate.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.openpeak.model.HardwareMetaData.setValueItem; nested exception is net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.openpeak.model.HardwareMetaData.setValueItem
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.openpeak.model.HardwareMetaData.setValueItem
at net.sf.hibernate.type.ComponentType.setPropertyValues(ComponentType.java:219)
at net.sf.hibernate.type.ComponentType.resolveIdentifier(ComponentType.java:390)
at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:145)
at net.sf.hibernate.collection.AbstractCollectionPersister.readElement(AbstractCollectionPersister.java:363)
at net.sf.hibernate.collection.Set.readFrom(Set.java:234)
at net.sf.hibernate.loader.Loader.readCollectionElement(Loader.java:305)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:219)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)
at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:340)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3089)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:831)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:851)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2081)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1955)
at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1891)
at org.springframework.orm.hibernate.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:188)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:149)
at org.springframework.orm.hibernate.HibernateTemplate.get(HibernateTemplate.java:186)
at com.openpeak.persistence.hibernate.ModelDAOHibernate.getModel(Unknown Source)
at com.openpeak.service.ModelManagerImpl.getModel(Unknown Source)
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.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:201)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:158)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:196)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:135)
at $Proxy0.getModel(Unknown Source)
at com.openpeak.web.listeners.ModelActionListener.processAction(Unknown Source)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:57)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:642)
at javax.faces.component.UICommand.broadcast(UICommand.java:297)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:266)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:380)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.cglib.beans.BulkBeanException
at com.openpeak.model.HardwareMetaData$$BulkBeanByCGLIB$$edc322bf.setPropertyValues(<generated>)
at net.sf.hibernate.type.ComponentType.setPropertyValues(ComponentType.java:215)
... 73 more
Caused by: java.lang.ClassCastException
... 75 more


Top
 Profile  
 
 Post subject: The xdoclet and java code
PostPosted: Fri Apr 02, 2004 1:16 pm 
Newbie

Joined: Tue Sep 30, 2003 12:59 pm
Posts: 8
Here is the code snippets:


The main model class:
Code:
<snip>

    /** The getter method for this HardwareMetaItem.
    *
    * @hibernate.set name="ircodes" table="opchildhardwaremetadata"
    * @hibernate.collection-key  column="model_id"
    * @hibernate.collection-composite-element class="com.openpeak.model.HardwareMetaData"
    */
    public Set getHardwareMetaData() {
        return(hardwareMetaData);
    }

    /** The setter method for this HardwareMetaItem.
     */
    public void setHardwareMetaData(Set hardwareMetaData) {
        this.hardwareMetaData = hardwareMetaData;
    }
<snip>


The Set mapping class:

Code:
<snip>

public class HardwareMetaData extends BaseObject implements Serializable {

   private HardwareMetaItem hardwareMetaItem;
   private ValueItem valueItem;

    /**
     * @return Returns the command.
     * @hibernate.property column="value_id"  type="int" not-null="true"
     */
    public ValueItem getValueItem() {
        return valueItem;
    }
    /**
     * @param value The ValueItem to set.
     */
    public void setValueItem(ValueItem valueItem) {
        this.valueItem = valueItem;
    }

    /**
     * @return Returns the hardwareMetaItem.
     * @hibernate.property column="meta_id"  type="int" not-null="true"
     */
    public HardwareMetaItem getHardwareMetaItem() {
        return hardwareMetaItem;
    }
    /**
     * @param hardwareMetaItem The hardwareMetaItem to set.
     */
    public void setHardwareMetaItem(HardwareMetaItem hardwareMetaItem) {
        this.hardwareMetaItem = hardwareMetaItem;
    }
<snip>


and the value item class(hardwaremetaitem is the same structure)

Code:
/**
* @hibernate.class table="opvalue"
*/

public class ValueItem extends BaseObject implements BaseItem, Serializable {

   private Long id;
   private String description;
   private boolean active;
   private java.util.Date modifiedDate;

<snip>
then the setters/getters/xdoclet


[/code]


Top
 Profile  
 
 Post subject: one more exception...
PostPosted: Fri Apr 02, 2004 4:04 pm 
Newbie

Joined: Tue Sep 30, 2003 12:59 pm
Posts: 8
14:56:55,838 ERROR BasicPropertyAccessor:60 - IllegalArgumentException in class: com.openpeak.model.HardwareMetaData, setter method of property: valueItem
14:56:55,848 ERROR BasicPropertyAccessor:64 - expected type: com.openpeak.model.item.ValueItem, actual value: java.lang.Long
14:56:55,858 INFO TransactionInterceptor:201 - Invoking rollback for transaction on method 'getModel' in class [com.openpeak.service.ModelManager] due to throwable [org.springframework.orm.hibernate.HibernateSystemException: IllegalArgumentException occurred while calling setter of com.openpeak.model.HardwareMetaData.valueItem; nested exception is net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.openpeak.model.HardwareMetaData.valueItem]
14:56:55,858 INFO HibernateTransactionManager:361 - Initiating transaction rollback
14:56:55,868 ERROR ModelActionListener:? - DAOException
org.springframework.orm.hibernate.HibernateSystemException: IllegalArgumentException occurred while calling setter of com.openpeak.model.HardwareMetaData.valueItem; nested exception is net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.openpeak.model.HardwareMetaData.valueItem
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.openpeak.model.HardwareMetaData.valueItem
at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:68)
at net.sf.hibernate.type.ComponentType.setPropertyValues(ComponentType.java:230)
at net.sf.hibernate.type.ComponentType.resolveIdentifier(ComponentType.java:390)
at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:145)
at net.sf.hibernate.collection.AbstractCollectionPersister.readElement(AbstractCollectionPersister.java:363)
at net.sf.hibernate.collection.Set.readFrom(Set.java:234)
at net.sf.hibernate.loader.Loader.readCollectionElement(Loader.java:305)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:219)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)
at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:340)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3089)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:831)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:851)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2081)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1955)
at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1891)
at org.springframework.orm.hibernate.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:181)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
at org.springframework.orm.hibernate.HibernateTemplate.get(HibernateTemplate.java:179)
at com.openpeak.persistence.hibernate.ModelDAOHibernate.getModel(Unknown Source)
at com.openpeak.service.ModelManagerImpl.getModel(Unknown Source)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 5:33 am 
Regular
Regular

Joined: Wed Mar 03, 2004 9:38 am
Posts: 70
@hibernate.property is only for types which have a corresponding Hibernate Type, i.e. primitive types, Date and perhaps a few others.

You need to map your ValueItem and HardwareItem classes with e.g. @hibernate.many-to-one or @hibernate.component.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 10:22 am 
Newbie

Joined: Tue Sep 30, 2003 12:59 pm
Posts: 8
joib wrote:
@hibernate.property is only for types which have a corresponding Hibernate Type, i.e. primitive types, Date and perhaps a few others.

You need to map your ValueItem and HardwareItem classes with e.g. @hibernate.many-to-one or @hibernate.component.


Thanks! I just caught that... not sure why I had the property tag in the code.

updated to:
@hibernate.many-to-one column="value_id" type="long" not-null="true"

and everything works great...


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.