Jitesh-

Okay, I've found your problem :) Basically when you turn on validation, you also turn on namespace processing in the parser (as far as I can tell it's required and validation won't work without it). By turning on namespace processing Castor searches for a namespace match between the element it is unmarshalling and the class descriptor used to handle the element. In your case, the element's namespace is "http://www.ne.jp/method"; and the class descriptor's namespace is "http://castor.exolab.org/";. These clash, and Castor declares it cannot find a match on the class descriptor.

Okay, long break to play around and figure out how to fix the problem...

Here we go. To avoid the above mentioned problem, you need to define your namespace in the mapping file and use it to declare the elements corresponding to the Java classes. Here's the updated mapping file I used:

<mapping xmlns="http://castor.exolab.org/";
    xmlns:jp="http://www.ne.jp/method";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://castor.exolab.org/ mapping.xsd" >

  <class name="TMSettings">
    <map-to xml="tmsettings" ns-uri="http://www.ne.jp/method";
      ns-prefix="jp" />

    <field name="loggerList" collection="map" get-method="getLoggerList"
      set-method="addLogger" type="TMLogger">
      <bind-xml name="jp:logger" location="logging"/>
    </field>
  </class>

  <class name="TMLogger">
    <field name="name" type="string">
      <bind-xml name="jp:name" node="attribute"/>
    </field>
    <field name="boundryLevel" type="string">
      <bind-xml name="jp:boundrylevel" node="attribute"/>
    </field>
  </class>

</mapping>

And here's the updated XML document:

<jp:tmsettings xmlns:jp="http://www.ne.jp/method";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://www.ne.jp/method settings.xsd">
  <jp:logging>
    <jp:logger name="tmcompiler" boundrylevel="10"/>
    <jp:logger name="tmclient" boundrylevel="10"/>
    <jp:logger name="tmwebapp" boundrylevel="10"/>
  </jp:logging>
</jp:tmsettings>

The only funny thing that arises is the location attribute, which apparently doesn't use the namespace prefix in the mapping file (I tried, I got an error *shrug*). But I've unmarshalled this successfully several times using these modifications.

I'm also not sure about the "round-trip" capability of these files. With namespaces turned on in Castor, it marshals the attributes of the logger elements with either the http://castor.exolab.org namespace or with the http://www.ne.jp/method namespace and I can't seem to manually introduce those namespaces in the xml file and have it unmarshal correctly. I think some experimentation might fix this, but I don't know the solution right now.

Hope that resolves the problem.

Stephen


Kalyani Jitesh wrote:
HI Stephen,

Thanks for your co-operation from beginning.

Please find attached the complete posted example in attached postexample.zip. I am also sending copy to your personal mailid as I am not sure mailing list can accept the attachment.
If you execute the TestMapping class you will get the same error as posted.

Please keep me posted about your findings.

Thanks And Regards,
Jitesh


----- Original Message ----- From: "Stephen Bash" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, August 19, 2005 9:47 PM
Subject: Re: [castor-user] [XML][Mapping] Error: unable to find FieldDescriptor when validation on


Jitesh-

I've been looking at your problem on and off recently, and I agree that unmarhsalling behaves well without validation. Unfortunately, I get "General Schema Error: Grammar with uri 2: http://castor.exolab.org/ , can not found." instead of the mapping error you're getting. I've attempted changing all references from exolab.org to codehaus.org, but I get the same error (just checking if the parser is attempting to contact the URL for some reason).

If you know how to get around this problem, I'll attempt to further test the situation.

Thanks,
Stephen


Kalyani Jitesh wrote:

HI Gregory,

Thanks for your mail. Yes I posting the same again and again to get some help. Actually all mapping is working fine without schema validation. But when I set following properties for validation, it is throwing this error.
But I am not able to find it out.

org.exolab.castor.parser.validation=true
org.exolab.castor.parser.namespaces=true
org.exolab.castor.sax.features=http://xml.org/sax/features/validation,http://apache.org/xml/features/validation/schema,http://apache.org/xml/features/validation/schema-full-checking Thanks And Regards,
Jitesh


----- Original Message ----- From: "Gregory Block" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, August 19, 2005 8:58 PM
Subject: Re: [castor-user] [XML][Mapping] Error: unable to find FieldDescriptor when validation on


I've seen this post several times, and have noticed that nobody else seems to be saying anything...

On 18 Aug 2005, at 09:02, Kalyani Jitesh wrote:

  <field name="loggerList" collection="map" get-method="getLoggerList"
   set-method="addLogger" type="TMLogger">



First point: I'm not familiar with maps, so I don't know if that will have an impact. I wasn't of the opinion that they could be used this way - someone will have to clarify.


   <bind-xml name="logger" location="logging"/>



Second: Not sure if that's enough to just say logging - thought you wanted logging/logger here. Don't know if you've already examined that, however.

 <class name="TMLogger">
  <field name="name" type="string">
   <bind-xml name="name" node="attribute"/>
    </field>
  <field name="boundryLevel" type="string">
   <bind-xml name="boundrylevel" node="attribute"/>
    </field>
 </class>
</mapping>



And again, I have no idea how this would ever be mapped to a name/ value pair on map. Don't you really want a List-based collection, rather than a map, for this?


Anyways, someone more familiar with the XML side will need to answer those questions for you. I imagine your first problem is in incorrect use of the location attribute, and maybe that will solve your problems - I honestly don't know. The use of a map seems odd, to me, but who knows - maybe that's what's intended.

Best of luck.


-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------




-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------



-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------


------------------------------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to