Subject: Re: unable to find FieldDescriptor in ClassDescriptor error - msg#00352
List: java.castor.devel
Hi Matt,
The problem is here:
<field name="requestParam"
type="org.ifmc.arp.common.util.RequestParamEntry"
handler="org.ifmc.arp.common.util.RequestParamHandler"/>
During unmarshalling Castor will find the <request-param> element and as
it stands it's mapped to the given field descriptor above which tells it
that <request-param> is a RequestParamEntry. So Castor creates a new
RequestParamEntry object.
Then the unmarshaller recieves <request-param-entry> child element and
is unable to
find a request-param-entry field inside of the previously created
RequestParamEntry which is currently the parent object.
So you can see the dilemma.
Since your requestParam contains a collection, I think you mark it as
such you'll be ok:
<field name="requestParam"
type="org.ifmc.arp.common.util.RequestParamEntry"
handler="org.ifmc.arp.common.util.RequestParamHandler"
collection="array" container="false"/>
collection="array" should be whatever is returned by your
RequestParamHandler. So if you return an arraylist, then use
collection="arraylist".
--Keith
Matt Goodwin wrote:
>
>
i have an object (request) that contains a hashmap (requestParam) that
>
contains a bunch of key/value pairs which all are strings. i'd like to
>
marshall and unmarshall this object. per a keith viscco post i did an object
>
which wraps the hashmap and created a custom field handler for it. thanks
>
for all the example code on the site!!! i can marshall to xml fine, but when
>
i try to take that xml and unmarshall it to a request object i get the
>
following error:
>
>
org.xml.sax.SAXException: unable to find FieldDescriptor for
>
'request-param-entry' in ClassDescriptor of request-param-entry
>
>
here is my xml file:
>
>
<?xml version="1.0" ?>
>
<request>
>
<failed-attempts>0</failed-attempts>
>
<notify>true</notify>
>
<parent-request-id>0</parent-request-id>
>
<request-date>2003-01-16T15:16:25.359</request-date>
>
<request-id>0</request-id>
>
<requestor>
>
<user-id>10</user-id>
>
<user-name>mgoodwin</user-name>
>
</requestor>
>
<requestor-id>10</requestor-id>
>
<request-param>
>
<request-param-entry
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
xsi:type="java:org.ifmc.arp.common.util.RequestParamEntry">
>
<key>phone</key>
>
<value>555555555</value>
>
</request-param-entry>
>
<request-param-entry
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
xsi:type="java:org.ifmc.arp.common.util.RequestParamEntry">
>
<key>password</key>
>
<value>password</value>
>
</request-param-entry>
>
</request-param>
>
</request>
>
>
here is the relevant parts of the mapping file:
>
>
<mapping>
>
<class name="org.ifmc.arp.bean.impl.Request" >
>
<map-to xml="request"/>
>
<field name="failedAttempts" type="integer" required="false" >
>
<bind-xml name="failed-attempts" node="element" />
>
</field>
>
<field name="notify" type="boolean" required="false"
>
get-method="isNotify" >
>
<bind-xml name="notify" node="element" />
>
</field>
>
<field name="parentRequest" type="org.ifmc.arp.bean.impl.Request"
>
required="false" >
>
<bind-xml name="parent-request" node="element" />
>
</field>
>
<field name="parentRequestId" type="integer" required="false" >
>
<bind-xml name="parent-request-id" node="element" />
>
</field>
>
<field name="requestDate" type="date" required="true" >
>
<bind-xml name="request-date" node="element" />
>
</field>
>
<field name="requestId" type="integer" required="true" >
>
<bind-xml name="request-id" node="element" />
>
</field>
>
<field name="requestor" type="org.ifmc.arp.bean.impl.User"
>
required="true" >
>
<bind-xml name="requestor" node="element" />
>
</field>
>
<field name="requestorId" type="integer" required="true" >
>
<bind-xml name="requestor-id" node="element"/>
>
</field>
>
<field name="requestParam"
>
type="org.ifmc.arp.common.util.RequestParamEntry"
>
handler="org.ifmc.arp.common.util.RequestParamHandler" />
>
</class>
>
>
<class name="org.ifmc.arp.common.util.RequestParamEntry" >
>
<map-to xml="request-param-entry" />
>
<field name="key" type="string" required="true" >
>
<bind-xml name="key" node="element" />
>
</field>
>
<field name="value" type="string" required="true" >
>
<bind-xml name="value" node="element" />
>
</field>
>
</class>
>
</mapping>
>
>
do i need to make a class descriptor. i'm not exactly sure how to.
>
>
-----------------------------------------------------------
>
If you wish to unsubscribe from this mailing, send mail to
>
minimalist@xxxxxxxxxx with a subject of:
>
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
minimalist@xxxxxxxxxx with a subject of:
unsubscribe castor-dev
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
unable to find FieldDescriptor in ClassDescriptor error
i have an object (request) that contains a hashmap (requestParam) that contains
a bunch of key/value pairs which all are strings. i'd like to marshall and
unmarshall this object. per a keith viscco post i did an object which wraps
the hashmap and created a custom field handler for it. thanks for all the
example code on the site!!! i can marshall to xml fine, but when i try to take
that xml and unmarshall it to a request object i get the following error:
org.xml.sax.SAXException: unable to find FieldDescriptor for
'request-param-entry' in ClassDescriptor of request-param-entry
here is my xml file:
<?xml version="1.0" ?>
<request>
<failed-attempts>0</failed-attempts>
<notify>true</notify>
<parent-request-id>0</parent-request-id>
<request-date>2003-01-16T15:16:25.359</request-date>
<request-id>0</request-id>
<requestor>
<user-id>10</user-id>
<user-name>mgoodwin</user-name>
</requestor>
<requestor-id>10</requestor-id>
<request-param>
<request-param-entry
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="java:org.ifmc.arp.common.util.RequestParamEntry">
<key>phone</key>
<value>555555555</value>
</request-param-entry>
<request-param-entry
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="java:org.ifmc.arp.common.util.RequestParamEntry">
<key>password</key>
<value>password</value>
</request-param-entry>
</request-param>
</request>
here is the relevant parts of the mapping file:
<mapping>
<class name="org.ifmc.arp.bean.impl.Request" >
<map-to xml="request"/>
<field name="failedAttempts" type="integer" required="false" >
<bind-xml name="failed-attempts" node="element" />
</field>
<field name="notify" type="boolean" required="false"
get-method="isNotify" >
<bind-xml name="notify" node="element" />
</field>
<field name="parentRequest" type="org.ifmc.arp.bean.impl.Request"
required="false" >
<bind-xml name="parent-request" node="element" />
</field>
<field name="parentRequestId" type="integer" required="false" >
<bind-xml name="parent-request-id" node="element" />
</field>
<field name="requestDate" type="date" required="true" >
<bind-xml name="request-date" node="element" />
</field>
<field name="requestId" type="integer" required="true" >
<bind-xml name="request-id" node="element" />
</field>
<field name="requestor" type="org.ifmc.arp.bean.impl.User"
required="true" >
<bind-xml name="requestor" node="element" />
</field>
<field name="requestorId" type="integer" required="true" >
<bind-xml name="requestor-id" node="element"/>
</field>
<field name="requestParam"
type="org.ifmc.arp.common.util.RequestParamEntry"
handler="org.ifmc.arp.common.util.RequestParamHandler" />
</class>
<class name="org.ifmc.arp.common.util.RequestParamEntry" >
<map-to xml="request-param-entry" />
<field name="key" type="string" required="true" >
<bind-xml name="key" node="element" />
</field>
<field name="value" type="string" required="true" >
<bind-xml name="value" node="element" />
</field>
</class>
</mapping>
do i need to make a class descriptor. i'm not exactly sure how to.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
minimalist@xxxxxxxxxx with a subject of:
unsubscribe castor-dev
Next Message by Date:
click to view message preview
Changing methode names
Hi there,
I am working on a Cobol CopyBook Parser which does
the following:
1). It reads a Cobol CopyBook
2). Converts it to a XML/XSD Scheme
3). Generate JAVA classes
I got this thing working now (still simple
copybooks only) but I have to following "challenge". Over here we use DDIS which
generates parameter names etc. for a copybook. These parameters are like this
for instance: P11410-G34745.
Example: a get exhange rate message of a currency
(EUR) on a certain date (01-01-2003) could be something like this:
<P11410>
<P11410-G12345>01-01-2003</P11410-G12345>
<P11410-G12346>EUR</P11410-G12346>
</P11410>
I created a XSD for the above stated example
and Castor generates a class with getters like:
setP11410G12345(String); // for the
date
setP11410G12346(String); // for the
isocode
What I want is that Castor generates class
methods like
setIsoCode(String)
setDate(String)
but it should marshall the code in
<P11410>
<P11410-G12345>01-01-2003</P11410-G12345>
<P11410-G12346>EUR</P11410-G12346>
</P11410>
insteadof
<Exchange-Rate>
<Date>01-01-2003</DATE>
<IsoCode>EUR</IsoCode>
</Exchange-Rate>
Is something possible?
Kind regards,
Arnoud
Wolfard.
Previous Message by Thread:
click to view message preview
unable to find FieldDescriptor in ClassDescriptor error
i have an object (request) that contains a hashmap (requestParam) that contains
a bunch of key/value pairs which all are strings. i'd like to marshall and
unmarshall this object. per a keith viscco post i did an object which wraps
the hashmap and created a custom field handler for it. thanks for all the
example code on the site!!! i can marshall to xml fine, but when i try to take
that xml and unmarshall it to a request object i get the following error:
org.xml.sax.SAXException: unable to find FieldDescriptor for
'request-param-entry' in ClassDescriptor of request-param-entry
here is my xml file:
<?xml version="1.0" ?>
<request>
<failed-attempts>0</failed-attempts>
<notify>true</notify>
<parent-request-id>0</parent-request-id>
<request-date>2003-01-16T15:16:25.359</request-date>
<request-id>0</request-id>
<requestor>
<user-id>10</user-id>
<user-name>mgoodwin</user-name>
</requestor>
<requestor-id>10</requestor-id>
<request-param>
<request-param-entry
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="java:org.ifmc.arp.common.util.RequestParamEntry">
<key>phone</key>
<value>555555555</value>
</request-param-entry>
<request-param-entry
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="java:org.ifmc.arp.common.util.RequestParamEntry">
<key>password</key>
<value>password</value>
</request-param-entry>
</request-param>
</request>
here is the relevant parts of the mapping file:
<mapping>
<class name="org.ifmc.arp.bean.impl.Request" >
<map-to xml="request"/>
<field name="failedAttempts" type="integer" required="false" >
<bind-xml name="failed-attempts" node="element" />
</field>
<field name="notify" type="boolean" required="false"
get-method="isNotify" >
<bind-xml name="notify" node="element" />
</field>
<field name="parentRequest" type="org.ifmc.arp.bean.impl.Request"
required="false" >
<bind-xml name="parent-request" node="element" />
</field>
<field name="parentRequestId" type="integer" required="false" >
<bind-xml name="parent-request-id" node="element" />
</field>
<field name="requestDate" type="date" required="true" >
<bind-xml name="request-date" node="element" />
</field>
<field name="requestId" type="integer" required="true" >
<bind-xml name="request-id" node="element" />
</field>
<field name="requestor" type="org.ifmc.arp.bean.impl.User"
required="true" >
<bind-xml name="requestor" node="element" />
</field>
<field name="requestorId" type="integer" required="true" >
<bind-xml name="requestor-id" node="element"/>
</field>
<field name="requestParam"
type="org.ifmc.arp.common.util.RequestParamEntry"
handler="org.ifmc.arp.common.util.RequestParamHandler" />
</class>
<class name="org.ifmc.arp.common.util.RequestParamEntry" >
<map-to xml="request-param-entry" />
<field name="key" type="string" required="true" >
<bind-xml name="key" node="element" />
</field>
<field name="value" type="string" required="true" >
<bind-xml name="value" node="element" />
</field>
</class>
</mapping>
do i need to make a class descriptor. i'm not exactly sure how to.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
minimalist@xxxxxxxxxx with a subject of:
unsubscribe castor-dev
Next Message by Thread:
click to view message preview
Changing methode names
Hi there,
I am working on a Cobol CopyBook Parser which does
the following:
1). It reads a Cobol CopyBook
2). Converts it to a XML/XSD Scheme
3). Generate JAVA classes
I got this thing working now (still simple
copybooks only) but I have to following "challenge". Over here we use DDIS which
generates parameter names etc. for a copybook. These parameters are like this
for instance: P11410-G34745.
Example: a get exhange rate message of a currency
(EUR) on a certain date (01-01-2003) could be something like this:
<P11410>
<P11410-G12345>01-01-2003</P11410-G12345>
<P11410-G12346>EUR</P11410-G12346>
</P11410>
I created a XSD for the above stated example
and Castor generates a class with getters like:
setP11410G12345(String); // for the
date
setP11410G12346(String); // for the
isocode
What I want is that Castor generates class
methods like
setIsoCode(String)
setDate(String)
but it should marshall the code in
<P11410>
<P11410-G12345>01-01-2003</P11410-G12345>
<P11410-G12346>EUR</P11410-G12346>
</P11410>
insteadof
<Exchange-Rate>
<Date>01-01-2003</DATE>
<IsoCode>EUR</IsoCode>
</Exchange-Rate>
Is something possible?
Kind regards,
Arnoud
Wolfard.