You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Andrei Petru Mura <ma...@gmail.com> on 2021/11/18 09:46:35 UTC

Camel-Freemarker: request isn't available in the freemarker script

Hi,

I have a camel route in Apache-Karaf 4.3.3. The script, is accessing the
request object like this:

${request.setHeader('test', 'someValue')}

But I get this error at runtime:

Tip: If the failing expression is known to legally refer to something
that's sometimes null or missing, either specify a default value like
myOptionalVar!myDefault, or use <#if
myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover
the last step of the expression; to cover the whole expression, use
parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
- Failed at: ${request.setHeader("test...  [in template ...

If I put this in my template:

${.vars.request},

I get this:

Unknown built-in: "request". Help (latest version):
https://freemarker.apache.org/docs/ref_builtins.html; you're using
FreeMarker 2.3.31.
The alphabetical list of built-ins:
abs, absolute_template_name, ancestors, api,
boolean, byte,
c, cap_first, capitalize, ceiling, children, chop_linebreak, chunk,
contains, counter,
date, date_if_unknown, datetime, datetime_if_unknown, default, double,
drop_while,
ends_with, ensure_ends_with, ensure_starts_with, esc, eval, eval_json,
exists,
filter, first, float, floor,
groups,
has_api, has_content, has_next, html,
if_exists, index, index_of, int, interpret, is_boolean, is_collection,
is_collection_ex, is_date, is_date_like, is_date_only, is_datetime,
is_directive, is_enumerable, is_even_item, is_first, is_hash, is_hash_ex,
is_indexable, is_infinite, is_last, is_macro, is_markup_output, is_method,
is_nan, is_node, is_number, is_odd_item, is_sequence, is_string, is_time,
is_transform, is_unknown_date_like, iso, iso_h, iso_h_nz, iso_local,
iso_local_h, iso_local_h_nz, iso_local_m, iso_local_m_nz, iso_local_ms,
iso_local_ms_nz, iso_local_nz, iso_m, iso_m_nz, iso_ms, iso_ms_nz, iso_nz,
iso_utc, iso_utc_fz, iso_utc_h, iso_utc_h_nz, iso_utc_m, iso_utc_m_nz,
iso_utc_ms, iso_utc_ms_nz, iso_utc_nz, item_cycle, item_parity,
item_parity_cap,
j_string, join, js_string, json_string,
keep_after, keep_after_last, keep_before, keep_before_last, keys,
last, last_index_of, left_pad, length, long, lower_abc, lower_case,
map, markup_string, matches, max, min,
namespace, new, next_sibling, no_esc, node_name, node_namespace, node_type,
number, number_to_date, number_to_datetime, number_to_time,
parent, previous_sibling,
remove_beginning, remove_ending, replace, reverse, right_pad, root, round,
rtf,
seq_contains, seq_index_of, seq_last_index_of, sequence, short, size, sort,
sort_by, split, starts_with, string, substring, switch,
take_while, then, time, time_if_unknown, trim, truncate, truncate_c,
truncate_c_m, truncate_m, truncate_w, truncate_w_m,
uncap_first, upper_abc, upper_case, url, url_path,
values,
web_safe, with_args, with_args_last, word_list,
xhtml, xml

How should I fix this issue?

N.B. The installed freemarker version is: 2.3.31.stable

Thanks,
Andrei M.

Re: Camel-Freemarker: request isn't available in the freemarker script

Posted by Andrea Cosentino <an...@gmail.com>.
Hello,

Please complete the description of the problem by reporting the
camel version you're using.

Il giorno gio 18 nov 2021 alle ore 10:46 Andrei Petru Mura <
mapandrei@gmail.com> ha scritto:

> Hi,
>
> I have a camel route in Apache-Karaf 4.3.3. The script, is accessing the
> request object like this:
>
> ${request.setHeader('test', 'someValue')}
>
> But I get this error at runtime:
>
> Tip: If the failing expression is known to legally refer to something
> that's sometimes null or missing, either specify a default value like
> myOptionalVar!myDefault, or use <#if
> myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover
> the last step of the expression; to cover the whole expression, use
> parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
> ----
>
> ----
> FTL stack trace ("~" means nesting-related):
> - Failed at: ${request.setHeader("test...  [in template ...
>
> If I put this in my template:
>
> ${.vars.request},
>
> I get this:
>
> Unknown built-in: "request". Help (latest version):
> https://freemarker.apache.org/docs/ref_builtins.html; you're using
> FreeMarker 2.3.31.
> The alphabetical list of built-ins:
> abs, absolute_template_name, ancestors, api,
> boolean, byte,
> c, cap_first, capitalize, ceiling, children, chop_linebreak, chunk,
> contains, counter,
> date, date_if_unknown, datetime, datetime_if_unknown, default, double,
> drop_while,
> ends_with, ensure_ends_with, ensure_starts_with, esc, eval, eval_json,
> exists,
> filter, first, float, floor,
> groups,
> has_api, has_content, has_next, html,
> if_exists, index, index_of, int, interpret, is_boolean, is_collection,
> is_collection_ex, is_date, is_date_like, is_date_only, is_datetime,
> is_directive, is_enumerable, is_even_item, is_first, is_hash, is_hash_ex,
> is_indexable, is_infinite, is_last, is_macro, is_markup_output, is_method,
> is_nan, is_node, is_number, is_odd_item, is_sequence, is_string, is_time,
> is_transform, is_unknown_date_like, iso, iso_h, iso_h_nz, iso_local,
> iso_local_h, iso_local_h_nz, iso_local_m, iso_local_m_nz, iso_local_ms,
> iso_local_ms_nz, iso_local_nz, iso_m, iso_m_nz, iso_ms, iso_ms_nz, iso_nz,
> iso_utc, iso_utc_fz, iso_utc_h, iso_utc_h_nz, iso_utc_m, iso_utc_m_nz,
> iso_utc_ms, iso_utc_ms_nz, iso_utc_nz, item_cycle, item_parity,
> item_parity_cap,
> j_string, join, js_string, json_string,
> keep_after, keep_after_last, keep_before, keep_before_last, keys,
> last, last_index_of, left_pad, length, long, lower_abc, lower_case,
> map, markup_string, matches, max, min,
> namespace, new, next_sibling, no_esc, node_name, node_namespace, node_type,
> number, number_to_date, number_to_datetime, number_to_time,
> parent, previous_sibling,
> remove_beginning, remove_ending, replace, reverse, right_pad, root, round,
> rtf,
> seq_contains, seq_index_of, seq_last_index_of, sequence, short, size, sort,
> sort_by, split, starts_with, string, substring, switch,
> take_while, then, time, time_if_unknown, trim, truncate, truncate_c,
> truncate_c_m, truncate_m, truncate_w, truncate_w_m,
> uncap_first, upper_abc, upper_case, url, url_path,
> values,
> web_safe, with_args, with_args_last, word_list,
> xhtml, xml
>
> How should I fix this issue?
>
> N.B. The installed freemarker version is: 2.3.31.stable
>
> Thanks,
> Andrei M.
>