Hi Gergely,

It's appears to be a bug, but you can remove the error by adding 

verify-constructable="false" to the appropriate class mapping.

--Keith


Gergely Gati wrote:
> 
> Thanks,
> 
> That was the problem. I left an old version of Castor in the classpath.
> 
> But I have another question.
> 
> Is it possible not to have a default (zero-arg) constructor for my
> persistent class?
> 
> I mapped the "name" attribute's set-method to '%1', something like this:
> 
> public MyClass(String name) {
>     this.name = name;
> }
> 
> But when I don't provide a default ctor, Castor says
> MappingException: MyClass is not constructable -- it does not contain a
> default public constructor.
> 
> If I do specify a default ctor, the class will be instantiated properly
> and the field will be set.
> The default ctor is never invoked (I checked), so it seems Castor tests
> for the presence of a default ctor without really needing it.
> 
> Is this a bug?
> 
> Gergely
> > -----Original Message-----
> > From: Keith Visco [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, November 25, 2003 1:35 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [castor-dev] Mapping to ctor arguments: "%1" not a valid
> > NMToken
> >
> >
> >
> > Which version of Castor are you using?
> >
> > --Keith
> >
> >
> > Gergely Gati wrote:
> > >
> > > Hi,
> > >
> > > I'm using Castor XML mapping.
> > > I tried to map an XML attribute to a constructor argument as
> described
> > > here:
> > >
> > > http://castor.exolab.org/xml-mapping.html#constructor-args
> > >
> > > But when I put an entry like this to my mapping file, I get the
> > > following error:
> > >
> > > <field name="foo" set-method="%1" get-method="getFoo" type="string">
> > >                   <bind-xml node="attribute"/>
> > >                </field>
> > >
> > > ValidationException: "%1" is not a valid NMToken.;
> > >    - location of error: XPATH: mapping/class/field/@set-method
> > >         at
> > > org.exolab.castor.xml.validators.NameValidator.validate(Unknown
> Source)
> > >
> > > What am I doing wrong?
> > >
> > > Thanks,
> > > Gergely Gati
> > >
> > > -----------------------------------------------------------
> > > 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