camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From angeloNZ <>
Subject SaxParseException when using @RecipientList and .beanRef()
Date Tue, 05 May 2009 22:53:25 GMT


I'm using Camel alongside ServiceMix to do content based routing.  I'm
trying out using the @RecipientList annotation in my code to do a dynamic
lookup of my intended endpoints from an external properties file.

This is my camel method:

    public String getTarget(@XPath("//request") String requestType) {
	  // do a lookup of the request value from the resource bundle
	  log.debug("Request type received = " + requestType);
	  String target = messageAccessor.getMessage(requestType);
	  if (target != null) {
		  target = JBI_SERVICE + target;
	  log.debug("Target retrieved = " + target);
	  return target;

The parameter to getTarget is an XPath evaluated value whose value I set
inside a custom Http Marshaler class.  Basically, my marshaler class creates
an on-the-fly xml body and sets it as the message body of the
MessageExchange class.  Excerpt from ServiceMix marshaler class:

StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"
           .append("<request>" + this.getRequestType() + "</request>")

String userCredentials = sb.toString();
        ByteArrayInputStream bais = new
        BufferedInputStream bis = new BufferedInputStream(bais);

        in.setContent(new StreamSource(bis));        
        me.setMessage(in, "in");

The value of the <request> element is what's being checked by my getTarget()
method.  The problem I'm encountering is I always get a "SaxParseException:
Content is not allowed in prolog" message doing this:


However, my old code doesn't have this problem:

	   .when().xpath("//request = 'RSS'")			       
	   .when().xpath("//request = 'REST'")

My log shows that I'm getting the endpoints correctly from my properties
file.  I'm just not sure what is causing the SaxParseException, surely I
should get the same error if I use my old code if my xml body is invalid
right?  Any help is much appreciated.
View this message in context:
Sent from the Camel - Users (activemq) mailing list archive at

View raw message