You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by di...@multitask.com.au on 2002/12/17 15:01:37 UTC
[jelly] 'bug' setting tag properties from properties file
Background:
I'm using the latka plugin.
It has a set of Jelly tags which have Strings for their setter methods,
i.e. the Request tag has a setHost(String) method.
Problem:
1) I populate these tags with an expression, which references properties
maven reads from project.properties, e.g.
<suite defaultHost="${latka.host}">
where latka.host is defined in the ${basedir}/project.properties
2) When the tag is executed, I get a
2002-12-17 13:29:52,798 DEBUG org.apache.commons.jelly.impl.TagScript -
Caught exception: java.lang.IllegalArgumentException: Property
'defaultHost' has no write method
java.lang.IllegalArgumentException: Property 'defaultHost' has no write
method
3) This is caused because the expression is being passed to BeanUtils with
no conversion done, e.g. :
2002-12-17 13:29:52,758 DEBUG org.apache.commons.jelly.JellyContext -
findVariable: latka.host value:
org.apache.commons.jelly.expression.ConstantExpression@502819[value=DEV270]
2002-12-17 13:29:52,758 DEBUG org.apache.commons.beanutils.BeanUtils -
setProperty(org.apache.commons.latka.jelly.SuiteTag@78aa80, defaultHost,
org.apache.commons.jelly.expression.ConstantExpression@502819[value=DEV270])
4) This tag has no methods that take an Expression as a paramter, and
since no conversion is being done by Jelly/BeanUtils the code fails with
the above IllegalArgumentException.
5) When these properties are passed in from the command prompt via
-Dlatka.host=DEV270 for example, all works fine, as they are explicitly
known as Strings.
Any idea where to start in fixing this?
--
dIon Gillard, Multitask Consulting
Blog: http://www.freeroller.net/page/dion/Weblog
Work: http://www.multitask.com.au
Re: [jelly] 'bug' setting tag properties from properties file
Posted by James Strachan <ja...@yahoo.co.uk>.
From: <di...@multitask.com.au>
> Background:
> I'm using the latka plugin.
> It has a set of Jelly tags which have Strings for their setter methods,
> i.e. the Request tag has a setHost(String) method.
>
> Problem:
> 1) I populate these tags with an expression, which references properties
> maven reads from project.properties, e.g.
>
> <suite defaultHost="${latka.host}">
>
> where latka.host is defined in the ${basedir}/project.properties
>
> 2) When the tag is executed, I get a
> 2002-12-17 13:29:52,798 DEBUG org.apache.commons.jelly.impl.TagScript -
> Caught exception: java.lang.IllegalArgumentException: Property
> 'defaultHost' has no write method
> java.lang.IllegalArgumentException: Property 'defaultHost' has no write
> method
>
> 3) This is caused because the expression is being passed to BeanUtils with
> no conversion done, e.g. :
> 2002-12-17 13:29:52,758 DEBUG org.apache.commons.jelly.JellyContext -
> findVariable: latka.host value:
>
org.apache.commons.jelly.expression.ConstantExpression@502819[value=DEV270]
> 2002-12-17 13:29:52,758 DEBUG org.apache.commons.beanutils.BeanUtils -
> setProperty(org.apache.commons.latka.jelly.SuiteTag@78aa80, defaultHost,
>
org.apache.commons.jelly.expression.ConstantExpression@502819[value=DEV270])
>
> 4) This tag has no methods that take an Expression as a paramter, and
> since no conversion is being done by Jelly/BeanUtils the code fails with
> the above IllegalArgumentException.
>
> 5) When these properties are passed in from the command prompt via
> -Dlatka.host=DEV270 for example, all works fine, as they are explicitly
> known as Strings.
TagScript already tries to evaluate any Expression objects before they are
set on properties on Tags. Maybe in this case we have multiply-nested
expressions inside Maven's JellyContext implementation? i.e. that an
expression evaluates to another expression, which when it evaluates the
final value is a String.
<aside>
Maybe when the variable scopes are introduced into Jelly this might fix any
errors like this that are introduced by Maven's JellyContext implementation.
</aside>
A workaround could be to patch TagScript to use the
expression.evaluateRecurse() rather than the expression.evaluate() methods?
I don't have time right now to investigate this but if you fancy having a
try, I've attached the patch to TagScript to do exactly this.
James
-------
http://radio.weblogs.com/0112098/
Re: [jelly] 'bug' setting tag properties from properties file
Posted by James Strachan <ja...@yahoo.co.uk>.
From: <di...@multitask.com.au>
> Background:
> I'm using the latka plugin.
> It has a set of Jelly tags which have Strings for their setter methods,
> i.e. the Request tag has a setHost(String) method.
>
> Problem:
> 1) I populate these tags with an expression, which references properties
> maven reads from project.properties, e.g.
>
> <suite defaultHost="${latka.host}">
>
> where latka.host is defined in the ${basedir}/project.properties
>
> 2) When the tag is executed, I get a
> 2002-12-17 13:29:52,798 DEBUG org.apache.commons.jelly.impl.TagScript -
> Caught exception: java.lang.IllegalArgumentException: Property
> 'defaultHost' has no write method
> java.lang.IllegalArgumentException: Property 'defaultHost' has no write
> method
>
> 3) This is caused because the expression is being passed to BeanUtils with
> no conversion done, e.g. :
> 2002-12-17 13:29:52,758 DEBUG org.apache.commons.jelly.JellyContext -
> findVariable: latka.host value:
>
org.apache.commons.jelly.expression.ConstantExpression@502819[value=DEV270]
> 2002-12-17 13:29:52,758 DEBUG org.apache.commons.beanutils.BeanUtils -
> setProperty(org.apache.commons.latka.jelly.SuiteTag@78aa80, defaultHost,
>
org.apache.commons.jelly.expression.ConstantExpression@502819[value=DEV270])
>
> 4) This tag has no methods that take an Expression as a paramter, and
> since no conversion is being done by Jelly/BeanUtils the code fails with
> the above IllegalArgumentException.
>
> 5) When these properties are passed in from the command prompt via
> -Dlatka.host=DEV270 for example, all works fine, as they are explicitly
> known as Strings.
TagScript already tries to evaluate any Expression objects before they are
set on properties on Tags. Maybe in this case we have multiply-nested
expressions inside Maven's JellyContext implementation? i.e. that an
expression evaluates to another expression, which when it evaluates the
final value is a String.
<aside>
Maybe when the variable scopes are introduced into Jelly this might fix any
errors like this that are introduced by Maven's JellyContext implementation.
</aside>
A workaround could be to patch TagScript to use the
expression.evaluateRecurse() rather than the expression.evaluate() methods?
I don't have time right now to investigate this but if you fancy having a
try, I've attached the patch to TagScript to do exactly this.
James
-------
http://radio.weblogs.com/0112098/