Peter,
The mapping is incorrect.If you are using Vector instead of collection then
the mapping should be
<field name="giftCertRedemption"
type="org.justgive.model.GiftCertificateRedemption" collection="vector">
<sql many-key="transactionid" />
<bind-xml name="gc-redemption" node="element" />
</field>
NOTE:I made the name of the field to "giftCertRedemption" instead of
"giftCertRedemptions".
The problem was that it tried to find a getGiftCertRedemptionss method (note
and extra 's'),which it was not able to find so it then tries to access the
field "giftCertRedemptions" directly , but as its private so it threw the
InvocationTargetException.
-Kalpesh
-----Original Message-----
From: peter c [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 02, 2004 2:53 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Help with java.lang.IllegalStateException: Field
access error:
When I attempt to Marshall a a Transaction object (see bewlow for details;
code/mapping),
which contains a GiftCertificateRedemption I get the following error:
java.lang.IllegalStateException: Field access error:
giftCertRedemptions(org.justgive.model.GiftCertificateRedemption) access
resulted
in exception: java.lang.reflect.InvocationTargetException
at
org.exolab.castor.mapping.loader.FieldHandlerImpl.getValue(FieldHandlerImpl.
java:383)
at
org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:195)
at
org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescripto
rImpl.java:892)
at org.exolab.castor.xml.Validator.validate(Validator.java:122)
at org.exolab.castor.xml.Marshaller.validate(Marshaller.java:2068)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:774)
etc....
Included is the basics of the Transaction class, the
GiftCertificateRedemptions
class and their mappings.
can anyone help??
thanks,
-peter
-----------------------------
public class Transaction implements TimeStampable, Persistent
{
private Integer id;
private Vector giftCertRedemptions;
public void setId(Integer newValue)
{
id = newValue;
}
public Integer getId()
{
return id;
}
public void setGiftCertRedemptions(Vector newValue)
{
this.giftCertRedemptions = newValue;
}
public Vector getGiftCertRedemptions()
{
return giftCertRedemptions;
}
public void addGiftCertRedemption(GiftCertificateRedemption newValue)
{
giftCertRedemptions.add(newValue);
}
}
public class GiftCertificateRedemption implements TimeStampable
{
public static Integer GIFT_PROFILE = new Integer(3672);
private Integer id;
private Integer transactionId;
private Integer amountRedeemed;
public Integer giftCertId;
public GiftCertificateRedemption()
{
//nada
}
public void setId(Integer newValue)
{
this.id = newValue;
}
public Integer getId()
{
return this.id;
}
public void setGiftCertId(Integer newValue)
{
giftCertId = newValue;
}
public Integer getGiftCertId()
{
return giftCertId;
}
public void setTransactionId(Integer newValue)
{
this.transactionId = newValue;
}
public Integer getTransactionId()
{
return this.transactionId;
}
public void setAmountRedeemed(Integer newValue)
{
this.amountRedeemed = newValue;
}
public Integer getAmountRedeemed()
{
return this.amountRedeemed;
}
}
<key-generator name="SEQUENCE" alias="TRANSSEQ">
<param name="sequence" value="transactions_trans_id_seq"/>
</key-generator>
<class name="org.justgive.model.Transaction" identity="id"
key-generator="TRANSSEQ">
<description>Models a transaction</description>
<map-to table="transactions" xml="transaction" />
<field name="id" type="integer" >
<sql name="trans_id" type="integer"/>
<bind-xml name="id" node="element"/>
</field>
<!-- giftCertRedemptions is a Vector of GiftCertificateRedemption
Objects -->
<field name="giftCertRedemptions"
type="org.justgive.model.GiftCertificateRedemption" collection="vector">
<sql many-key="transactionid" />
<bind-xml name="gc-redemption" node="element" />
</field>
</class>
<key-generator name="SEQUENCE" alias="GIFTCERTREDEEMSEQ">
<param name="sequence" value="gc_redemptions_redemptionid_seq"/>
</key-generator>
<class name="org.justgive.model.GiftCertificateRedemption" identity="id"
key-generator="GIFTCERTREDEEMSEQ"
depends="org.justgive.model.Transaction">
<description>Models a Gift Certificate redemption</description>
<map-to table="gc_redemptions" xml="gc-redemptions" />
<field name="id" type="integer" >
<sql name="redemptionid" type="integer"/>
<bind-xml name="id" node="element"/>
</field>
<field name="transactionId" type="integer" >
<sql name="transactionid" type="integer"/>
<bind-xml name="transaction-id" node="element"/>
</field>
<field name="giftCertId" type="integer" >
<sql name="giftcertid" type="integer"/>
<bind-xml name="giftcert-id" node="element"/>
</field>
<field name="amountRedeemed" type="integer" >
<sql name="amountredeemed" type="integer" />
<bind-xml name="amount-redeemed" node="element"/>
</field>
</class>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev