-->
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: IllegalArgumentException occurred while calling setter
PostPosted: Fri Mar 20, 2009 1:44 pm 
Beginner
Beginner

Joined: Mon May 26, 2008 3:34 am
Posts: 31
Hello everyone,

I am trying to get a list of article resources and i am getting the following exception:
Code:
com.elnominal.exception.InfrastructureException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.elnominal.model.resource.ArticleResource.resourceCategory
   at com.elnominal.dao.ArticleDAO.findAll(ArticleDAO.java:110)
   at com.elnominal.servlet.SearchDataFilter.doFilter(SearchDataFilter.java:37)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.elnominal.servlet.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:104)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.elnominal.model.resource.ArticleResource.resourceCategory
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
   at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3571)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:133)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
   at org.hibernate.loader.Loader.doQuery(Loader.java:729)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:63)
   at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
   at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
   at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:844)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241)
   at org.hibernate.loader.Loader.doList(Loader.java:2213)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
   at com.elnominal.dao.ArticleDAO.findAll(ArticleDAO.java:108)
   ... 16 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
   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:597)
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
   ... 38 more



this is my hbm file for ArticleResource:
Code:
<hibernate-mapping package="com.elnominal.model.resource">

<class name="ArticleResource" table="elnominal_article_resource" lazy="true">

   <id name="id" type="integer" column="id" unsaved-value="null">
      <generator class="sequence">
         <param name="sequence">elnominal_article_resource_id_seq</param>
      </generator>
   </id>

   <property name="title" type="string" column="title" length="40" not-null="true" unique-key="UNIQUE_NAME_AT_LEVEL"/>
   <property name="description" type="string" column="description" length="200" not-null="false"/>
   <property name="fileName" type="string" column="file_name" length="200" not-null="false"/>
   <property name="filePath" type="string" column="file_path" length="200" not-null="false"/>
   <property name="creationDate" column="creation_date" type="java.util.Date" update="false" not-null="true"/>   

   <many-to-one name="resourceCategory" cascade="none" class="com.elnominal.model.category.ResourceCategory" column="id_category" not-null="false" />

</class>

</hibernate-mapping>



and my ArticleResource class:
Code:
...

private int id = 0;
   private String title = null;
   private String description = null;   
   private String fileName;
   private String filePath;
   private Date creationDate = new Date();
   private ResourceCategory resourceCategory = null;
   
   public ArticleResource() {}
   
   public String getTitle() { return this.title; }   
   public void setTitle(String title) { this.title = title; }
   
   public String getDescription() { return this.description; }   
   public void setDescription(String description) { this.description = description; }
   
   public String getFileName() { return this.fileName; }   
   public void setFileName(String fileName) { this.fileName = fileName; }
   
   public String getFilePath() { return this.filePath; }   
   public void setFilePath(String filePath) { this.filePath = filePath; }
   
   public Date getCreationDate() { return this.creationDate;   }   
   public void setCreationDate(Date creationDate) { this.creationDate = creationDate; }
   
   public ResourceCategory getResourceCategory() { return this.resourceCategory; }   
   public void setResourceCategory(ResourceCategory resourceCategory) { this.resourceCategory = resourceCategory; }

...


Can someone help me? i am really stuck at this,

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 20, 2009 5:25 pm 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
check that the resourcecategory is really not nullable in your DB. I think I've seen this exception when something is null in the DB, but you're mapping is setup to not expect null... and show us the resourcecategory mapping, because it could be that the datatypes are not matching in that mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 20, 2009 5:52 pm 
Beginner
Beginner

Joined: Mon May 26, 2008 3:34 am
Posts: 31
Hello jlawmi, thanks for your response.

Indeed resourceCategory is not nullable in my DB, but still getting the same error.

Here is my resourceCategory mapping, its a union-subclass strategy:
Code:
<hibernate-mapping package="com.elnominal.model.category">

<class name="Category" lazy="true">

   <id name="id" type="integer" column="id" unsaved-value="null">
      <generator class="native"/>
   </id>

   <property name="title" type="string" column="title" length="40" not-null="true" unique-key="UNIQUE_NAME_AT_LEVEL"/>
   <property name="description" type="string" column="description" length="200" not-null="false"/>

   <many-to-one name="parentCategory" cascade="none" outer-join="false">
      <column name="id_parent" not-null="false" unique-key="UNIQUE_NAME_AT_LEVEL"/>
   </many-to-one>

   <property name="creationDate" column="creation_date" type="java.util.Date" update="false" not-null="true"/>   

   <union-subclass name="UserCategory" table="elnominal_user_category" />
   <union-subclass name="ProfileCategory" table="elnominal_profile_category" />
   <union-subclass name="ArticleCategory" table="elnominal_article_category" />
   <union-subclass name="ResourceCategory" table="elnominal_resource_category" />

</class>

</hibernate-mapping>


and my Category.java:
Code:
/** Serial version ID. */
   private static final long serialVersionUID = -9093525414764126719L;
   
   /** Category ID. */
   private int id = 0;
   
   /** Category title. */
   private String title = null;
   
   /** Category description. */
   private String description = null;
   
   /** Parent category. */
   private Category parentCategory;
   
   /** Child categories. */
   private Set<Category> childCategories = new HashSet<Category>();
   
   /** Creation date. */
   private Date creationDate = new Date();


my resourceCategory class extends from Category.

Any other idea?

Thanks again


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 22, 2009 10:41 am 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
Might want to set a breakpoint in here:

at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
at or

either in your setter, or in the hibernate code...

One more idea... I think I've seen this error when I have a primitive in my object, but there is a null in the DB. This happens because hibernate can't set a primitive value to null... Is there any chance you have categories in the db that don't have an id value?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 22, 2009 1:41 pm 
Beginner
Beginner

Joined: Mon May 26, 2008 3:34 am
Posts: 31
Thanks again for the help, jlawmi.

I will try later because right now i am getting another error, so i cant test it.


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.