[mule-user] mule expressions and URIs.... # misery

4 views
Skip to first unread message

Ross Paul

unread,
May 1, 2009, 5:54:51 PM5/1/09
to us...@mule.codehaus.org

I'm trying to use mule expressions in an outbound endpoint. Unfortunately,
if I use more than one, the multiple # causes the URI to become invalid,
since # is a special character denoting a uri fragment. Hex encoding also
doesn't work since [ isn't a valid character outside of the fragment.
I've got a work around utilizing service overrides, but it's fairly ugly...
has anyone run into this and found a clean way around it?
--
View this message in context: http://www.nabble.com/mule-expressions-and-URIs....---misery-tp23340332p23340332.html
Sent from the Mule - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Andrew Perepelytsya

unread,
May 1, 2009, 6:06:50 PM5/1/09
to us...@mule.codehaus.org
Example?

Andrew

Ross Paul

unread,
May 1, 2009, 6:12:17 PM5/1/09
to us...@mule.codehaus.org

I'm using my own FileMessageDispatcher which can dynamically create
directories and do atomic writes. Ideally I'd like to do something like
this:

<outbound>
<pass-through-router>
<file:outbound-endpoint
path="/#[mule:context.serviceName]#[mule:context.serviceName]"
outputPattern="Mule4Ever.txt"/>
</pass-through-router>
</outbound>

(obviously a toy example)

If i only use one expression in the path i'm golden

--
View this message in context: http://www.nabble.com/mule-expressions-and-URIs....---misery-tp23340332p23340564.html

Andrew Perepelytsya

unread,
May 1, 2009, 6:14:39 PM5/1/09
to us...@mule.codehaus.org
Have you tried nesting them in a #[string:] evaluator? This is a documented solution, btw.

Andrew

Ross Paul

unread,
May 1, 2009, 6:24:55 PM5/1/09
to us...@mule.codehaus.org

you mean like:
path="/#[string:#[mule:context.serviceName]#[mule:context.serviceName]]"

That also doesn't work because path is used to build a URI. The issue is
the multiple # in the URI. My hacky solution is to ignore path completely
and simply set the whole path on outputPattern.

Stack trace is:
java.net.URISyntaxException: Illegal character in fragment at index 17:
file:///#[string:#[mule:context.serviceName]#[mule:context.serviceName]]
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at java.net.URI$Parser.parse(URI.java:3028)
at java.net.URI.<init>(URI.java:578)
at org.mule.endpoint.MuleEndpointURI.<init>(MuleEndpointURI.java:146)
at org.mule.endpoint.URIBuilder.getEndpoint(URIBuilder.java:173)
at
org.mule.endpoint.AbstractEndpointBuilder.getProperties(AbstractEndpointBuilder.java:265)
at
org.mule.endpoint.AbstractEndpointBuilder.doBuildOutboundEndpoint(AbstractEndpointBuilder.java:164)
at
org.mule.endpoint.AbstractEndpointBuilder.buildOutboundEndpoint(AbstractEndpointBuilder.java:93)
at
org.mule.endpoint.DefaultEndpointFactory.getOutboundEndpoint(DefaultEndpointFactory.java:86)

--
View this message in context: http://www.nabble.com/mule-expressions-and-URIs....---misery-tp23340332p23340708.html

Andrew Perepelytsya

unread,
May 1, 2009, 6:27:59 PM5/1/09
to us...@mule.codehaus.org

Your stacktrace assumes you haven't called expressionManager.parse(). Is it really the case?

Andrew

P.S. nice to see you back on the lists :)

On May 1, 2009 6:24 PM, "Ross Paul" <ross...@mlb.com> wrote:


you mean like:
path="/#[string:#[mule:context.serviceName]#[mule:context.serviceName]]"

That also doesn't work because path is used to build a URI.  The issue is
the multiple # in the URI.  My hacky solution is to ignore path completely
and simply set the whole path on outputPattern.

Stack trace is:
java.net.URISyntaxException: Illegal character in fragment at index 17:
file:///#[string:#[mule:context.serviceName]#[mule:context.serviceName]]
       at java.net.URI$Parser.fail(URI.java:2809)
       at java.net.URI$Parser.checkChars(URI.java:2982)
       at java.net.URI$Parser.parse(URI.java:3028)
       at java.net.URI.<init>(URI.java:578)
       at org.mule.endpoint.MuleEndpointURI.<init>(MuleEndpointURI.java:146)
       at org.mule.endpoint.URIBuilder.getEndpoint(URIBuilder.java:173)
       at
org.mule.endpoint.AbstractEndpointBuilder.getProperties(AbstractEndpointBuilder.java:265)
       at
org.mule.endpoint.AbstractEndpointBuilder.doBuildOutboundEndpoint(AbstractEndpointBuilder.java:164)
       at
org.mule.endpoint.AbstractEndpointBuilder.buildOutboundEndpoint(AbstractEndpointBuilder.java:93)
       at
org.mule.endpoint.DefaultEndpointFactory.getOutboundEndpoint(DefaultEndpointFactory.java:86)

Andrew Perepelytsya wrote: > > Have you tried nesting them in a #[string:] evaluator? This is ...

Sent from the Mule - User mailing list archive at Nabble.com. ------------------------------------...

Ross Paul

unread,
May 1, 2009, 7:12:44 PM5/1/09
to us...@mule.codehaus.org

I'm my code, yes i do call expressionManager.parse(). However, the stack
trace below never actually makes it to my code; it's a startup failure (only
1 expression in the path starts up fine and resolves the expression fine).

And i'm glad to be posting again (instead of just lurking!). Mule 2 has
been a delight to use

--
View this message in context: http://www.nabble.com/mule-expressions-and-URIs....---misery-tp23340332p23341240.html


Sent from the Mule - User mailing list archive at Nabble.com.

Ross Paul

unread,
May 4, 2009, 12:35:55 PM5/4/09
to us...@mule.codehaus.org

My current decentish solution is to override org.mule.util.TemplateParser and
change the WIGGLY_MULE_TEMPLATE_PATTER to "(\\$\\@[^$]+\\$|#\\[[^#]+\\])"

While i'm not in love with the syntax, it allows me to use multiple
expressions in a URI and preserves backwards computability with the current
syntax. Basically this allows:

address="file:///$@header:URI_SAFE$/$@header:URI_SAFE$"
or
address="file:///#[header:NOT_URI_SAFE_I_CAN_ONLY_USE_ONE_EXPRESSION]

--
View this message in context: http://www.nabble.com/mule-expressions-and-URIs....---misery-tp23340332p23371947.html

Alan Cassar

unread,
May 5, 2009, 11:58:38 AM5/5/09
to us...@mule.codehaus.org
try
path="#[string:/#[mule:context.serviceName]#[mule:context.serviceName]]"

Alan Cassar, Software Engineer | Tel: +356 21334457 | Fax: +356 21 334156
ricston Ltd., Northfields Suite 4, Independence Avenue, Mosta MST9026 - MALTA

email:  alan....@ricston.com | web:http://www.ricston.com


----------
Disclaimer - This email and any files transmitted with it are confidential and contain privileged or copyright information. You must not present this message to another party without first gaining permission from the sender. If you are not the intended recipient you must not copy, distribute or use this email or the information contained in it for any purpose other than to notify us. If you have received this message in error, please notify the sender immediately and delete this email from your system. We do not guarantee that this material is free from viruses or any other defects although due care has been taken to minimise the risk. Any views stated in this communication are those of the actual sender and not necessarily those of Ricston Ltd. or its subsidiaries.

Ross Paul

unread,
May 5, 2009, 12:23:55 PM5/5/09
to us...@mule.codehaus.org

Alan,
That doesn't work either. When mule starts up, it resolves the endpoint
into a URI before any expressions are evaluated, so you cannot include more
than one # in the URI (or a connector specific attribute which is used to
assemble a uri). That's why my TemplateParser listed above uses URI
friendly characters as the deliminators

Ross

Alan Cassar-2 wrote:
>
> try
>
> path="#[string:/#[mule:context.serviceName]#[mule:context.serviceName]]"
>
> Alan Cassar, Software Engineer | Tel: +356 21334457 | Fax: +356 21 334156
> ricston Ltd., Northfields Suite 4, Independence Avenue, Mosta MST9026 -
> MALTA
>

> email: alan....@ricston.com <mailto:alan....@ricston.com> |
> web:http://www.ricston.com <http://www.ricston.com/>
>
>
> ----------
> *Disclaimer* - This email and any files transmitted with it are

--
View this message in context: http://www.nabble.com/mule-expressions-and-URIs....---misery-tp23340332p23390949.html

Reply all
Reply to author
Forward
0 new messages