Because URL has no default public constructor.

When you pass it in as a root object Castor doesn't do this check (since
you can pass in an instatiated root object to the unmarshaller as well)
but when the object is embedded deeper in your class hierarchy Castor is
the one that needs to create the object. So if it has no default public
constructor then it won't be introspected and therefor not included in
your output.

There are a couple ways of dealing with this:

1. Return a string instead of a URL

-or-

2. Write your own FieldHandler (extend GeneralizedFieldHandler) to
convert the URL to and from a string 

  - Requires a mapping file to be used to specify the handler.


--Keith

Werner Thiemann wrote:
> 
> Hello Erik,
> 
> I am not using a mapping-file.
> 
> But I don't think that thats the problem.
> The problem is (and thats the reason I put this on the developers mailing
> list), that when I create an URL and marshal it straight I get a propper URL
> representation in my XML file. But when I wrap an Object around it, I don't
> get the URL in the XML file. It just disapears...
> When I put other objects into my wrapping-object they all work.
> Until now I found only one exception: URL
> 
> Ciao
> Werner
> 
> -----Urspr�ngliche Nachricht-----
> Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Gesendet: Freitag, 24. Januar 2003 15:19
> An: [EMAIL PROTECTED]
> Betreff: Re: [castor-dev] marshal a URL
> 
> Werner,
> 
> Are you using the generated Descriptors or a mapping file?
> 
> --Erik
> 
>       > -----Original Message-----
>       > From: Werner Thiemann [mailto:[EMAIL PROTECTED]]
>       > Sent: Friday, January 24, 2003 2:36 AM
>       > To: [EMAIL PROTECTED]
>       > Subject: [castor-dev] marshal a URL
>       >
>       >
>       > Hello!
>       >
>       > When I tried to marshal this it worked just fine:
>       >
>       > URL url = new URL("http://www.blue-age.de/index.html";);
>       > Marshaller.marshal(url,f);
>       >
>       > but when I tried to put the URL in an object, just like this:
>       >
>       > URL url = new URL("http://www.blue-age.de/index.html";);
>       > TestObject tob = new TestObject();
>       > tob.setUrl(url);
>       > Marshaller.marshal(tob,f);
>       >
>       > while TestObject is as simple as:
>       >
>       > URL url;
>       >
>       > public URL getUrl(){
>       >         return url;
>       > }
>       >
>       > public void setUrl(URL url){
>       >         this.url = url;
>       > }
>       >
>       > here is the XML-File i get:
>       >
>       > <?xml version="1.0" encoding="UTF-8" ?>
>       > <test-object />
>       >
>       > Can anyone explain to me what is wrong?
>       > Thank you!
>       >
>       > //Werner Thiemann
>       >
>       > -----------------------------------------------------------
>       > 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
> 
> -----------------------------------------------------------
> 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

Reply via email to