Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: IllegalArgumentException occurred calling getter
PostPosted: Fri Oct 05, 2007 4:06 pm 
Newbie

Joined: Fri Oct 05, 2007 4:02 pm
Posts: 1
Hi

I'm currently having a problem with Spring and Hibernate. If anyone has any suggestions, please let me know.

My problem is this. I am trying to wire a generic property editor into a controller. Whenever I post to that controller, the property editor gets called and attempts to load an object using a provided manager. When the manager calls its "get" method, I get this exception:

ERROR [http-8080-Processor24] BasicPropertyAccessor.get(167) | IllegalArgumentException in class: net.myOrg.baseClasses.BaseObject, getter method of property: id
ERROR [http-8080-Processor24] AbstractFlushingEventListener.performExecutions(30 1) | Could not synchronize database state with session
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of net.myOrg.baseClasses.BaseObject.id
at org.hibernate.property.BasicPropertyAccessor$Basic Getter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.entity.AbstractEntityTuplizer. getIdentifier(AbstractEntityTuplizer.java:183)
at org.hibernate.persister.entity.AbstractEntityPersi ster.getIdentifier(AbstractEntityPersister.java:35 39)
at org.hibernate.persister.entity.AbstractEntityPersi ster.isTransient(AbstractEntityPersister.java:3255 )
at org.hibernate.engine.ForeignKeys.isTransient(Forei gnKeys.java:181)
at org.hibernate.engine.ForeignKeys.getEntityIdentifi erIfNotUnsaved(ForeignKeys.java:218)
at org.hibernate.type.EntityType.getIdentifier(Entity Type.java:397)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyT oOneType.java:78)
at org.hibernate.persister.collection.AbstractCollect ionPersister.writeElement(AbstractCollectionPersis ter.java:755)
at org.hibernate.persister.collection.AbstractCollect ionPersister.recreate(AbstractCollectionPersister. java:1143)
at org.hibernate.action.CollectionRecreateAction.exec ute(CollectionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQue ue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:143)
at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:298)
at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:1000)
at org.hibernate.impl.SessionImpl.managedFlush(Sessio nImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(J DBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doCommit(HibernateTransactionManager. java:575)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.processCommit(AbstractPla tformTransactionManager.java:662)
at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:632)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.commitTransactionAfterReturning (TransactionAspectSupport.java:314)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:117)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :161)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy306.get(Unknown Source)
at net.myOrg.beans.PropertyEditor.setAsText(PropertyE ditor.java:38)
at org.springframework.beans.TypeConverterDelegate.do ConvertTextValue(TypeConverterDelegate.java:326)
at org.springframework.beans.TypeConverterDelegate.do ConvertValue(TypeConverterDelegate.java:310)
at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:192)
at org.springframework.beans.TypeConverterDelegate.co nvertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:815)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:645)
at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractPropertyAccessor.java:7 8)
at org.springframework.validation.DataBinder.applyPro pertyValues(DataBinder.java:532)
at org.springframework.validation.DataBinder.doBind(D ataBinder.java:434)
at org.springframework.web.bind.WebDataBinder.doBind( WebDataBinder.java:147)
at org.springframework.web.bind.ServletRequestDataBin der.bind(ServletRequestDataBinder.java:108)
at org.springframework.web.servlet.mvc.BaseCommandCon troller.bindAndValidate(BaseCommandController.java :369)
at org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestInternal(AbstractFormControl ler.java:248)
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:857)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:461)
at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:426)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@169dd14
at sun.reflect.GeneratedMethodAccessor903.invoke(Unkn own Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.property.BasicPropertyAccessor$Basic Getter.get(BasicPropertyAccessor.java:145)
... 119 more

Here is my code for the property editor:

Code:

Code:
public class PropertyEditor<T, PK extends Serializable> extends PropertyEditorSupport {

    private Manager<T, PK> mgr;
    private Class<PK> primaryKeyClass;

    public void setMgr(Manager<T, PK> mgr) {
        this.mgr = mgr;
    }

    public void setPrimaryKeyClass(Class<PK> primaryKeyClass) {
        this.primaryKeyClass = primaryKeyClass;
    }

    public PropertyEditor() {}
   
    public PropertyEditor(final Manager<T, PK> mgr, final Class<PK> primaryKeyClass) {
        super();
        this.mgr = mgr;
        this.primaryKeyClass = primaryKeyClass;
    }
   
    public void setAsText(String primaryKey) {
       
        if (StringUtils.isEmpty(primaryKey)) {
            setValue(null);
        }
        else {
            setValue(mgr.get((PK) ConvertUtils.convert(primaryKey, primaryKeyClass)));
        }
    }


I have it wired in my context like this:

Code:

Code:
<bean id="organizationPropertyEditor" class="net.myOrg.beans.PropertyEditor">
      <property name="mgr" ref="organizationManager"/>
      <property name="primaryKeyClass" value="java.lang.Long"/>
</bean>


I have the organization manager wired like this:

Code:

Code:
<bean id="organizationManager" class="net.myOrg.service.impl.DaoBasedManager">
   <constructor-arg>
      <bean class="net.myOrg.dao.hibernate.DaoHibernate">
         <constructor-arg value="net.myOrg.intranet.model.Organization"/>
         <property name="sessionFactory" ref="sessionFactory"/>
      </bean>
   </constructor-arg>
</bean>


The DaoBasedManager and DaoHibernate are generic classes that I am wiring in.

The organizationManager works in other places that I am using it, but when I use it in this property editor, that is when it throws the exception. Please let me know if anyone has any ideas.

Thank you,
Ben Scribner


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 06, 2007 2:51 pm 
Regular
Regular

Joined: Sun Sep 30, 2007 7:51 pm
Posts: 92
There is some ClassCastException:

Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@169dd14
at sun.reflect.GeneratedMethodAccessor903.invoke(Unkn own Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.hibernate.property.BasicPropertyAccessor$Basic Getter.get(BasicPropertyAccessor.java:145)

Can you trace this in your BaseObject class ?

Pavol


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 12:44 pm 
Newbie

Joined: Thu Jul 12, 2007 12:22 pm
Posts: 4
Hello,

I encoured the same problem.

I have an objet with 2 many-to-one relation (cascade = all).

During a database migration, on 50000 records read, 48000 are correctly persisted and 2000 failed with the same error.

If you find a solution, could you please tell me.

Best Regard.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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.