Parsing URI's with multiple parameters w/ Spring

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Parsing URI's with multiple parameters w/ Spring

Aaron Crickenberger
Using the latest from camel's trunk, I modified camel-spring's
simpleRoute.xml so the route looks like this:

<route>
  <from uri="direct:start?paramA=1&paramB=2"/>
  <to uri="mock:result"/>
</route>

Running "mvn -Dtest=SimpleRouteTest test" then gives me the following
stacktrace:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 28 in XML document from class path resource
[org/apache/camel/spring/example/simpleRoute.xml] is invalid; nested
exception is org.xml.sax.SAXParseException: The reference to entity
"paramB" must end with the ';' delimiter.
Caused by: org.xml.sax.SAXParseException: The reference to entity
"paramB" must end with the ';' delimiter.
   at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
   at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
   at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
   at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
   at
com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
   at
com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:856)
   at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:578)
   at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:222)
   at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
   at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
   at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
   at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
   at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
   at
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
   at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
   at
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
   at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)
   at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
   at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
   at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
   at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
   at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
   at
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
   at
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
   at
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
   at
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
   at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
   at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
   at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
   at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
   at
org.apache.camel.spring.example.SimpleRouteTest.createApplicationContext(SimpleRouteTest.java:39)

This seems to happen for any uri that has multiple parameters in its
query string (eg:
"ftp://camel-user@localhost:123/tmp?password=secret&binary=true" which
parses fine in camel-core's UriConfigurationTest.)  My XML kung-fu is
weak, so I'm not quite sure where to begin.

Maybe a red herring, but I see the following messages during the
[antrun:run {execution: process-sources}] step:

/Users/acricken/workspaces/apache/camel/components/camel-spring/target/schema-src/org/apache/camel/spring/CamelBeanPostProcessor.java:37:
package org.apache.camel.spring.util does not exist
import org.apache.camel.spring.util.ReflectionUtils;
                                    ^
/Users/acricken/workspaces/apache/camel/components/camel-spring/target/schema-src/org/apache/camel/spring/CamelBeanPostProcessor.java:62:
cannot find symbol
symbol  : class SpringCamelContext
location: class org.apache.camel.spring.CamelBeanPostProcessor
    private SpringCamelContext camelContext;

(and then a bunch more cannot find symbol : class SpringCamelContext)

Any ideas?

-aaron
Reply | Threaded
Open this post in threaded view
|

Re: Parsing URI's with multiple parameters w/ Spring

jstrachan
On 8/15/07, Aaron Crickenberger <[hidden email]> wrote:
> Using the latest from camel's trunk, I modified camel-spring's
> simpleRoute.xml so the route looks like this:
>
> <route>
>   <from uri="direct:start?paramA=1&paramB=2"/>
>   <to uri="mock:result"/>
> </route>

So when XML encoding URIs, you need to use &amp; instead of &. So this
should do the trick...

<from uri="direct:start?paramA=1&amp;paramB=2"/>

Sometimes XML is a total pain in the ass - I mean who uses entity
references any more.

BTW I've added a FAQ entry on this as I see other folks hitting this XML pain...
http://cwiki.apache.org/CAMEL/how-do-i-use-uris-with-parameters-in-xml.html

> Maybe a red herring, but I see the following messages during the
> [antrun:run {execution: process-sources}] step:
>
> /Users/acricken/workspaces/apache/camel/components/camel-spring/target/schema-src/org/apache/camel/spring/CamelBeanPostProcessor.java:37:
> package org.apache.camel.spring.util does not exist
> import org.apache.camel.spring.util.ReflectionUtils;

Oh thats just a warning (I wish I could figure out how to hide) when
running the XSD generation step - you can safely ignore those.
Basically I don't think the classpath is exactly right so that the
JAXB2 code generation of the XSD does have warnings.

--
James
-------
http://macstrac.blogspot.com/