-->
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.  [ 10 posts ] 
Author Message
 Post subject: yet another IllegalArgumentException post - really need help
PostPosted: Fri Jan 19, 2007 2:58 pm 
Newbie

Joined: Fri Jan 19, 2007 1:41 pm
Posts: 8
I am receiving the following error

SEVERE: IllegalArgumentException in class: pmco.pojos.Competitor, getter method of property: id

with what I consider to be a fairly simple parent child relationship between two objects, Scenario being the parent and Competitor being the child. Scenario contains a list of Competitors. The link is one to many and for the moment it is satisfactory for it to be uni-directional from the parent to the child. There is a simple foreign key relationship between the two objects, although not explicitly formed as a constraint in the db.

These two objects are in fact in a hierarchy of parent child objects. I am citing these two as representative of my issue although it happens elsewhere (everywhere else) in the object graph.

I am running Hibernate on the server side of an Adobe Flex project and leaving the marshalling of the calls to Hibernate to the Adobe Hibernate adaptor, which has been proven to work elsewhere and I do not think is the source of this issue. I therefore don't have any code calling Hibernate directly, just the mapping files. The whole thing is running inside a JBoss server instance (any hints on how to attach an Eclipse debugger to my jar code running insde JBoss also gratefully received).

I have read a large number of posts about this error as it seems to be a common mistake that beginners make using Hibernate and I myself am a beginner. There have also been quite a few replies to the issue but none of them shows a really satisfactory conclusion and none seem to relate precisely to my issue as my object structure and relationship seems to be simpler in form. There seems to be a suggestion that either my getter should return a class instance or I have the mapping wrong

I would greatly appreciate help as this is the last remaining issue preventing me from fully adopting the otherwise excellent Hibernate in my project. I'm certain this is my error and am seeking guidance.

Hibernate version:3.2.1ga

Code:

My HSQLDB DDL
Code:
CREATE MEMORY TABLE SCENARIO(
   SCENARIO_ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
   USER_SCENARIO_ID INTEGER,
   PLANPOINT_ID INTEGER,
   TITLE VARCHAR(255),
   SEQUENCE INTEGER,
   POTENTIAL DOUBLE)

CREATE MEMORY TABLE COMPETITOR(
   COMPETITOR_ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
   SCENARIO_ID INTEGER,
   USER_SCENARIO_ID INTEGER,
   PLANPOINT_ID INTEGER,
   NAME VARCHAR(255),
   X DOUBLE,
   Y DOUBLE,
   RADIUS DOUBLE,
   ACTUAL DOUBLE,
   PROPOSITIONS DOUBLE,
   ORDER_SIZE DOUBLE,
   CONVERSION_RATE DOUBLE)


My Mapping doc
Code:
   <class name="Scenario" table="SCENARIO">
      <id name="id" column="SCENARIO_ID" type="int">
         <generator class="increment" />
      </id>
      <property name="planpoint_id" column="PLANPOINT_ID" type="int" />
      <property name="user_scenario_id" column="USER_SCENARIO_ID" type="int" />
      <property name="name" column="TITLE" type="string" length="255" />
      <property name="sequence" column="SEQUENCE" type="int" />
      <property name="potential" column="POTENTIAL" type="double" />
      <bag name="competitors" cascade="all">
         <key column="SCENARIO_ID"/>
         <one-to-many class="Competitor"/>
      </bag>
   </class>

   <class name="Competitor" table="COMPETITOR">
      <id name="id" column="COMPETITOR_ID" type="int">
         <generator class="increment" />
      </id>
      <property name="planpoint_id" column="PLANPOINT_ID" type="int" />
      <property name="user_scenario_id" column="USER_SCENARIO_ID" type="int" />
      <property name="scenario_id" column="SCENARIO_ID" type="int" />
      <property name="name" column="NAME" type="string" length="255" />
      <property name="x" column="X" type="double" />
      <property name="y" column="Y" type="double" />
      <property name="radius" column="RADIUS" type="double" />
      <property name="actual" column="ACTUAL" type="double" />
      <property name="propositions" column="PROPOSITIONS" type="double" />
      <property name="order_size" column="ORDER_SIZE" type="double" />
      <property name="conversion_rate" column="CONVERSION_RATE" type="double" />
   </class>


My Parent Scenario pojo
Code:
public class Scenario
{
   private List competitors;
   private String name;
   private int id;
   private int planpoint_id;
   private int user_scenario_id;
   private int sequence;
   private double potential;
   
   public List getCompetitors() {
      return competitors;
   }
   public void setCompetitors(List competitors) {
      this.competitors = competitors;
   }
   public String getName() {
      return name;
   }
   public void setName(String name) {
      this.name = name;
   }
   public int getId() {
      return id;
   }
   public void setId(int id) {
      this.id = id;
   }
   public int getSequence() {
      return sequence;
   }
   public void setSequence(int sequence) {
      this.sequence = sequence;
   }
   public int getUser_scenario_id() {
      return user_scenario_id;
   }
   public void setUser_scenario_id(int userscenario_id) {
      this.user_scenario_id = userscenario_id;
   }
   public int getPlanpoint_id() {
      return planpoint_id;
   }
   public void setPlanpoint_id(int planpoint_id) {
      this.planpoint_id = planpoint_id;
   }
   public double getPotential() {
      return potential;
   }
   public void setPotential(double potential) {
      this.potential = potential;
   }
}


My child competitor pojo
Code:
public class Competitor
{
   private String name;
   private double actual;
   private double x;
   private double y;
   private double radius;
   private int id;
   private int user_scenario_id;
   private int scenario_id;
   private int planpoint_id;
   private double propositions;
   private double order_size;
   private double conversion_rate;
   
   public double getActual() {
      return actual;
   }
   public void setActual(double actual) {
      this.actual = actual;
   }
   public int getId() {
      return id;
   }
   public void setId(int id) {
      this.id = id;
   }
   public String getName() {
      return name;
   }
   public void setName(String name) {
      this.name = name;
   }
   public int getPlanpoint_id() {
      return planpoint_id;
   }
   public void setPlanpoint_id(int planpoint_id) {
      this.planpoint_id = planpoint_id;
   }

   public double getConversion_rate() {
      return conversion_rate;
   }

   public void setConversion_rate(double conversion_rate) {
      this.conversion_rate = conversion_rate;
   }

   public double getOrder_size() {
      return order_size;
   }

   public void setOrder_size(double order_size) {
      this.order_size = order_size;
   }
   public double getPropositions() {
      return propositions;
   }
   public void setPropositions(double propositions) {
      this.propositions = propositions;
   }
   public int getScenario_id() {
      return scenario_id;
   }
   public void setScenario_id(int scenario_id) {
      this.scenario_id = scenario_id;
   }
   public int getUser_scenario_id() {
      return user_scenario_id;
   }
   public void setUser_scenario_id(int user_scenario_id) {
      this.user_scenario_id = user_scenario_id;
   }
   public double getRadius() {
      return radius;
   }
   public void setRadius(double radius) {
      this.radius = radius;
   }
   public double getX() {
      return x;
   }
   public void setX(double x) {
      this.x = x;
   }
   public double getY() {
      return y;
   }
   public void setY(double y) {
      this.y = y;
   }
}


Full stack trace of any exception that occurs:

Here is a portion of the stack trace generated by JBoss including a section which is generated by Flex, the full one is a meg...

2007-01-19 12:23:43,889 ERROR [STDERR] 19-Jan-2007 12:23:43 org.hibernate.property.BasicPropertyAccessor$BasicGetter get
SEVERE: IllegalArgumentException in class: pmco.pojos.Competitor, getter method of property: id
2007-01-19 12:23:43,889 INFO [STDOUT] [Flex] Serializing AMF/RTMP response
Version: 3
(Command method=_error (0) trxId=4)
(Typed Object #0 'flex.messaging.messages.ErrorMessage')
rootCause = (Typed Object #1 'org.hibernate.PropertyAccessException')
throwables = (Array #2)
[0] = (Ref #1)
[1] = (Typed Object #3 'java.lang.IllegalArgumentException')
localizedMessage = "java.lang.ClassCastException@493b65"
message = "java.lang.ClassCastException@493b65"
cause = null
persistentClass = (Typed Object #4 'java.lang.Class')
localizedMessage = "IllegalArgumentException occurred calling getter of pmco.pojos.Competitor.id"
propertyName = "id"
message = "IllegalArgumentException occurred calling getter of pmco.pojos.Competitor.id"
cause = (Ref #3)
throwableCount = 2
messages = (Array #5)
[0] = "IllegalArgumentException occurred calling"
[1] = "java.lang.ClassCastException@493b65"
destination = "planpoint.hibernate"
headers = (Object #6)
correlationId = "B4532402-B4F3-877D-B36D-3B629F888A9E"
faultString = "Could not invoke sync method on data adapter for destination 'planpoint.hibernate' due to the following error: class org.hibernate.PropertyAccessException:IllegalArgumentException occurred calling getter of pmco.pojos.Competitor.id."
messageId = "A0FBCA02-011D-5083-2228-1A55D61E33FD"
faultCode = "Server.Processing"
timeToLive = 0.0
extendedData = null
faultDetail = null
clientId = null
timestamp = 1.169227423889E12
body = null

Name and version of the database you are using:HSQLDB

Thanks in advance for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 5:34 pm 
Beginner
Beginner

Joined: Wed Oct 25, 2006 12:10 pm
Posts: 41
Hi Simon
I have a similar problem. Please let me know if found a fix to your problem

Regards
Bansi


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 6:29 pm 
Beginner
Beginner

Joined: Tue May 23, 2006 4:10 pm
Posts: 38
Location: Charleston, SC
I'm not sure if this is your problem but I see one big mistake looking at your code. Don't use primitives for properties in POJOs that are being persisted to a database, use objects. I'm fairly certain Hibernate is trying to pass an object and not an int to your POJO's setter method and that would cause an IllegalArgumentException. So, replace all your int properties with Integer, all your double properties with Double, and try again. Remember, null is not a legal value for primitives in Java; it is a legal value in a database, so use objects for persistent properties, not primitives.

Grant


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 7:21 pm 
Beginner
Beginner

Joined: Wed Oct 25, 2006 12:10 pm
Posts: 41
Hi Grant
Thanks for response. My posting is at http://forum.hibernate.org/viewtopic.php?t=969981

Please take few minutes to lookt my posting

Any pointers/suggestions will be highly appreciated

Regards
Bansi


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 9:55 pm 
Newbie

Joined: Fri Jan 19, 2007 1:41 pm
Posts: 8
Grant,

Thanks for taking the time to respond and I understand about the null issue with primitives, but I don't think it is the culprit here. To make double sure I have adjusted all my pojo code to use Java objects so there is not a primitive in sight and I still get the same error.

There's obviously some subtlety at play which I am missing and the number of people like me who have encountered this problem suggests there is a common misconception. If you google the IllegalArgumentException you'll see that there are a *lot* of people encountering it and I can't find a single place where it is adequately described or its cause and a fix documented.

I really don't consider my example to be complicated and it is a very common logical data model. Hibernate obvisouly copes with a parent child so it is just an issue of communication. I'm damned if I can figure it out though. All the example code I have seen is so trivial as to be useless.

I have also consulted two good books on the subject (Hibernate in Action and Hibernate Quickly, both of which I recommend) and I really can't see what I'm doing wrong.

I have also tried starting from the bottom and defining a one to many rather than a many to one - even though they are logically different they are semantically the same, all to no avail.

I think I'm going to boild my code down to the bare bones and see if I can find out what is causing it. Right now this is stopping us in our tracks. Without resolution to it I have to question our adoption of Hibernate for the project, which will be a great shame.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 10:22 pm 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Looking at the flex stacktrace, it indicates a ClassCastException. Browsing through the flex docs indicates that it does some kind of conversion for primitives into objects, Im not an expert on Flex but you might want to strip out flex, try out a simple example to see if it works without flex. Hibernate does not require that your properties be objects but if flex requires it, then you might want to try it out that way.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 10:25 pm 
Beginner
Beginner

Joined: Tue May 23, 2006 4:10 pm
Posts: 38
Location: Charleston, SC
I'm kind of wondering if the problem is somehow related to your database or maybe jboss is the culprit. I also noticed a ClassCastException in your post which would lead me to believe you might have a classloader issue. Could you try a different database or test your mappings and POJOs outside the jboss environment? I've certainly seen strange errors/exceptions reported by Hibernate that really had nothing to do with the underlying problem. We had some issues some months ago that were only resolved by placing breakpoints in the CacheSynchronization class to actually see what was happening. Hibernate was swallowing the real exception. The only exception we observed in the weblogic logs was a RollbackException, not the real exception, which I believe was a TransientObjectException in our case.

Grant


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 5:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it is pretty simple:

Look at the *full* stacktrace and *iif* this is done by hibernate look at the things written to the log (hibernate provides more technical context in there when an error happens doing property set/get)


otherwise the exception reported does not look like a hibernate "thing"

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 1:50 pm 
Newbie

Joined: Fri Jan 19, 2007 1:41 pm
Posts: 8
Max,

thanks for the reply. Would you mind stating which log you are referring to. The stack trace I gave was from the JBoss server.log. I have spelunked around my machine looking for other logs but I can't see anything which relates to Hibernate. I'm happy to believe there is more information out there for me to find, I've just run out of places to look.

Thanks
Simon


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 1:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are showing 10-15 lines of flex logging and only one line of hibernate log.

You should look in the log above that BasicPropertyAccessor line; it says what types/arguments are being used.

_________________
Max
Don't forget to rate


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