You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ychawla <pr...@yahoo.com> on 2008/11/22 00:09:41 UTC

Validation Component in Java 1.6.10

Hello All,
I am trying to validation an XML instance example using the Camel Validation
component.  It works fine with Java 1.5.0_06 but fails in Java 1.6.0_10. 
The exception I see is this:

SEVERE: Failed delivery for exchangeId: ID-yogesh/33005-1227308469932/0-0.
On delivery attempt: 0 caught: org.w3c.dom.DOMException: NOT_FOUND_ERR: An
attempt is made to reference a node in a context where it does not exist.
org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to reference a
node in a context where it does not exist.
	at
com.sun.org.apache.xerces.internal.dom.ElementImpl.setIdAttributeNode(ElementImpl.java:947)
	at
com.sun.org.apache.xerces.internal.jaxp.validation.DOMResultBuilder.startElement(DOMResultBuilder.java:252)
	at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:688)
	at
com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:273)
	at
com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:240)
	at
com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:186)
	at
com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:100)
	at
org.apache.camel.processor.validation.ValidatingProcessor.process(ValidatingProcessor.java:67)
	at
org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
	at
org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:61)
	at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
	at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:79)
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:84)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:75)
	at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:172)
	at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:93)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:63)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:50)
	at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
	at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:79)
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:84)
	at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:47)
	at
org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.java:153)
	at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:89)
	at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:99)
	at org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:65)
	at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)

I wrote a simple validation JUnit test with java 1.6 and the validation
worked fine.  

Here is the example booking document:
http://www.wijiscommons.org/bookingSchemaTest/booking.xml

And here is the zip of the schemas:
http://www.wijiscommons.org/bookingSchemaTest/booking-scenario.zip

Here is the simple route:
    <route>
      <from uri="file:/someDropOff"/>
      <convertBodyTo type="java.lang.String"/>
      <to
uri="validator:file:/booking-scenario/xsd/lexs/publish-discover/3.1/publish-discover.xsd"/>
	        <!-- we must configure the on exception within the route, as
opposed to Java DSL where we can do this outside -->
	        <onException>
	            <!-- the exception is full qualified names as plain strings -->
	            <!-- there can be more just add a 2nd, 3rd exception element
(unbounded) -->
	            <exception>org.apache.camel.ValidationException</exception>
	            <!-- we can set the redelivery policy here as well -->
	            <redeliveryPolicy maximumRedeliveries="0"/>
	            <!-- mark this as handled -->
	            <handled>
	              <constant>true</constant>
	            </handled>
	            <!-- let our order service handle this exception, call the
orderFailed method -->
		    <to uri="file:/someError"/>
	        </onException>
    </route>

I have a sneaking suspicion that this has something to do with all the
schemas being nested.  No proof this, but I saw a similiar ticket for
service mix with the same error and nested schemas for WSDL generation.

Any help would be appreciated.  :confused:

Thanks,
Yogesh


-- 
View this message in context: http://www.nabble.com/Validation-Component-in-Java-1.6.10-tp20631074s22882p20631074.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Validation Component in Java 1.6.10

Posted by ychawla <pr...@yahoo.com>.
Here was the validation code that succeeded in Java 1.6

	    // parse an XML document into a DOM tree
		try {
		DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
	    Document document = parser.parse(new File("/booking.xml"));

	    // create a SchemaFactory capable of understanding WXS schemas
	    SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

	    // load a WXS schema, represented by a Schema instance
	    Source schemaFile = new StreamSource(new
File("/booking-scenario/xsd/lexs/publish-discover/3.1/publish-discover.xsd"));
	    Schema schema = factory.newSchema(schemaFile);

	    // create a Validator instance, which can be used to validate an
instance document
	    Validator validator = schema.newValidator();

	    // validate the DOM tree
	    
	        validator.validate(new DOMSource(document));
	    } catch (Exception e) {
	        // instance document is invalid!
	    }
-- 
View this message in context: http://www.nabble.com/Validation-Component-in-Java-1.6.10-tp20631074s22882p20631103.html
Sent from the Camel - Users mailing list archive at Nabble.com.