You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by erh <EH...@transunion.com> on 2009/08/31 20:28:12 UTC

Using JSP EL expression language in camel

I'm trying to use the JSP EL according to the example listed on
http://camel.apache.org/el.html
It claims that you can call arbitrary functions with camel's version of the
EL, with the example shown being:
   <el>${in.body.replaceAll('id','orderId')}</el>

However, when I try to use something like that, I get an exception like
this:
Caused by: javax.el.MethodNotFoundException: Cannot resolve method
'replaceAll' in 'class java.lang.String'
        at
de.odysseus.el.tree.impl.ast.AstMethod.resolveMethod(AstMethod.java:67)
        at de.odysseus.el.tree.impl.ast.AstMethod.eval(AstMethod.java:97)
        at de.odysseus.el.tree.impl.ast.AstBinary.eval(AstBinary.java:97)
        at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:42)
        at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:28)
        at
de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:121)
        at
org.apache.camel.language.juel.JuelExpression.evaluate(JuelExpression.java:63)
       etc...

I didn't think that the JSP EL allowed for calling functions in this way. 
It talks about defining EL functions using static java methods and calling
them like this:
    ${fn:replaceAll(in.body, 'id', 'orderId')}
but that complains about not being able to resovle fn:replaceAll.
So, how is this supposed to work in Camel?

I'm using camel 1.6.2-SNAPSHOT as of August 14th and juel 2.1.2.

eric
-- 
View this message in context: http://www.nabble.com/Using-JSP-EL-expression-language-in-camel-tp25228176p25228176.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using JSP EL expression language in camel

Posted by erh <EH...@transunion.com>.

Claus Ibsen-2 wrote:
> 
> Hi
> 
> I have fixed the sample page and removed the replaceAll.
> 
> 

oh, ok.  I guess that'll be a little better.

I figured out a bit more about being able to call methods.  Apparently the
"MethodExpression" in the unified EL is meant to be used by JSF to define a
deferred method that will be called some time "in the future" with the
parameters provided "by java code".
It looks like calling methods that take no parameters actually works in
Camel, but the standard Unified EL doesn't support specifying parameters.

Another bit of interesting information is that Camel's
BeanAndMethodELResolver.findMethod method has a special case to look for
methods with one parameter.  This appears to have been added in r631503 by
jstrachan, and it has a reference to issue CAMEL-347, but for some reason I
can't get to issue.apache.org to look up the details on that right now.

I also found that there is a JBoss extension (called "Seam") that *does*
implement passing parameters from a EL expression, which might contribute to
additional confusion.

An explanation of this on that el.html page would be helpful to help keep
other people from wasting time with this.

It looks like I need to find some other way to do what I need to do. :(

eric
-- 
View this message in context: http://www.nabble.com/Using-JSP-EL-expression-language-in-camel-tp25228176p25229631.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using JSP EL expression language in camel

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have fixed the sample page and removed the replaceAll.




On Mon, Aug 31, 2009 at 9:18 PM, erh<EH...@transunion.com> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>> On Mon, Aug 31, 2009 at 8:28 PM, erh<EH...@transunion.com> wrote:
>>>
>>> I'm trying to use the JSP EL according to the example listed on
>>> http://camel.apache.org/el.html
>>> It claims that you can call arbitrary functions with camel's version of
>>> the
>>> EL, with the example shown being:
>>>   <el>${in.body.replaceAll('id','orderId')}</el>
>>>
>>> However, when I try to use something like that, I get an exception like
>>> this:
>>> Caused by: javax.el.MethodNotFoundException: Cannot resolve method
>>> 'replaceAll' in 'class java.lang.String'
>>>        at
>>> de.odysseus.el.tree.impl.ast.AstMethod.resolveMethod(AstMethod.java:67)
>>>        at de.odysseus.el.tree.impl.ast.AstMethod.eval(AstMethod.java:97)
>>>        at de.odysseus.el.tree.impl.ast.AstBinary.eval(AstBinary.java:97)
>>>        at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:42)
>>>        at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:28)
>>>        at
>>> de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:121)
>>>        at
>>> org.apache.camel.language.juel.JuelExpression.evaluate(JuelExpression.java:63)
>>>       etc...
>>>
>>> I didn't think that the JSP EL allowed for calling functions in this way.
>>> It talks about defining EL functions using static java methods and
>>> calling
>>> them like this:
>>>    ${fn:replaceAll(in.body, 'id', 'orderId')}
>>> but that complains about not being able to resovle fn:replaceAll.
>>> So, how is this supposed to work in Camel?
>>>
>>> I'm using camel 1.6.2-SNAPSHOT as of August 14th and juel 2.1.2.
>>>
>>
>> Hmm are you sure about EL being limited to not invoke methods on objects?
>> It could be as its JSP + JSF based EL and thus targeted for the web
>> world which could have all sorts of limitations.
>>
>> You can use a more powerful language such as: Groovy, MVEL, OGNL etc.
>> instead.
>>
>>
>
> I know the standard JSP language doesn't allow for it.  I don't know about
> JSF EL.  I'd prefer not to have to learn yet another language (nor try to
> explain it to the other developers).
> Clearly, someone came up with the example on that page in the first place,
> so I'm hoping whoever wrote that might chime in with an explanation of how
> he got it to work.
>
> eric
> --
> View this message in context: http://www.nabble.com/Using-JSP-EL-expression-language-in-camel-tp25228176p25228941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Using JSP EL expression language in camel

Posted by erh <EH...@transunion.com>.

Claus Ibsen-2 wrote:
> 
> On Mon, Aug 31, 2009 at 8:28 PM, erh<EH...@transunion.com> wrote:
>>
>> I'm trying to use the JSP EL according to the example listed on
>> http://camel.apache.org/el.html
>> It claims that you can call arbitrary functions with camel's version of
>> the
>> EL, with the example shown being:
>>   <el>${in.body.replaceAll('id','orderId')}</el>
>>
>> However, when I try to use something like that, I get an exception like
>> this:
>> Caused by: javax.el.MethodNotFoundException: Cannot resolve method
>> 'replaceAll' in 'class java.lang.String'
>>        at
>> de.odysseus.el.tree.impl.ast.AstMethod.resolveMethod(AstMethod.java:67)
>>        at de.odysseus.el.tree.impl.ast.AstMethod.eval(AstMethod.java:97)
>>        at de.odysseus.el.tree.impl.ast.AstBinary.eval(AstBinary.java:97)
>>        at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:42)
>>        at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:28)
>>        at
>> de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:121)
>>        at
>> org.apache.camel.language.juel.JuelExpression.evaluate(JuelExpression.java:63)
>>       etc...
>>
>> I didn't think that the JSP EL allowed for calling functions in this way.
>> It talks about defining EL functions using static java methods and
>> calling
>> them like this:
>>    ${fn:replaceAll(in.body, 'id', 'orderId')}
>> but that complains about not being able to resovle fn:replaceAll.
>> So, how is this supposed to work in Camel?
>>
>> I'm using camel 1.6.2-SNAPSHOT as of August 14th and juel 2.1.2.
>>
> 
> Hmm are you sure about EL being limited to not invoke methods on objects?
> It could be as its JSP + JSF based EL and thus targeted for the web
> world which could have all sorts of limitations.
> 
> You can use a more powerful language such as: Groovy, MVEL, OGNL etc.
> instead.
> 
> 

I know the standard JSP language doesn't allow for it.  I don't know about
JSF EL.  I'd prefer not to have to learn yet another language (nor try to
explain it to the other developers).
Clearly, someone came up with the example on that page in the first place,
so I'm hoping whoever wrote that might chime in with an explanation of how
he got it to work.

eric
-- 
View this message in context: http://www.nabble.com/Using-JSP-EL-expression-language-in-camel-tp25228176p25228941.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using JSP EL expression language in camel

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 31, 2009 at 8:28 PM, erh<EH...@transunion.com> wrote:
>
> I'm trying to use the JSP EL according to the example listed on
> http://camel.apache.org/el.html
> It claims that you can call arbitrary functions with camel's version of the
> EL, with the example shown being:
>   <el>${in.body.replaceAll('id','orderId')}</el>
>
> However, when I try to use something like that, I get an exception like
> this:
> Caused by: javax.el.MethodNotFoundException: Cannot resolve method
> 'replaceAll' in 'class java.lang.String'
>        at
> de.odysseus.el.tree.impl.ast.AstMethod.resolveMethod(AstMethod.java:67)
>        at de.odysseus.el.tree.impl.ast.AstMethod.eval(AstMethod.java:97)
>        at de.odysseus.el.tree.impl.ast.AstBinary.eval(AstBinary.java:97)
>        at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:42)
>        at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:28)
>        at
> de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:121)
>        at
> org.apache.camel.language.juel.JuelExpression.evaluate(JuelExpression.java:63)
>       etc...
>
> I didn't think that the JSP EL allowed for calling functions in this way.
> It talks about defining EL functions using static java methods and calling
> them like this:
>    ${fn:replaceAll(in.body, 'id', 'orderId')}
> but that complains about not being able to resovle fn:replaceAll.
> So, how is this supposed to work in Camel?
>
> I'm using camel 1.6.2-SNAPSHOT as of August 14th and juel 2.1.2.
>

Hmm are you sure about EL being limited to not invoke methods on objects?
It could be as its JSP + JSF based EL and thus targeted for the web
world which could have all sorts of limitations.

You can use a more powerful language such as: Groovy, MVEL, OGNL etc. instead.



> eric
> --
> View this message in context: http://www.nabble.com/Using-JSP-EL-expression-language-in-camel-tp25228176p25228176.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus