Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1066350

Summary: xsd validation fails when using xsd schema files with import statements
Product: [JBoss] JBoss Fuse Service Works 6 Reporter: Yusuf Koer <ykoer>
Component: SwitchYardAssignee: Rick Wagner <rwagner>
Status: CLOSED CURRENTRELEASE QA Contact: ppecka <ppecka>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.0.0 GACC: cobrien, khowell, ldimaggi, rwagner, soa-p-jira, toigaras
Target Milestone: CR3   
Target Release: 6.0.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
PATCH NAME: 1066350 PRODUCT NAME: JBoss Fuse Service Works VERSION: 6.0.0 GA SHORT DESCRIPTION: xsd validation fails when using xsd schema files with import statements LONG DESCRIPTION: xsd validation fails when using xsd schema files with import statements MANUAL INSTALL INSTRUCTIONS: Backup and remove the following files: $JBOSS_HOME/modules/system/layers/soa/org/apache/camel/core/main/camel-core-2.10.0.redhat-60024.jar Extract the file from the zip to the following locations: $JBOSS_HOME/modules/system/layers/soa/org/apache/camel/core/main/camel-core-2.10.0.redhat-60024_CAMEL7036_CAMEL6538.jar Change the file $JBOSS_HOME/modules/system/layers/soa/org/apache/camel/core/main/modules.xml so it references the correct jar name: <resources> <resource-root path="camel-core-2.10.0.redhat-60024_CAMEL7036_CAMEL6538.jar"/> </resources> Instructions to uninstall: Restore the following files that were backed up before the patch was installed: $JBOSS_HOME/modules/system/layers/soa/org/apache/camel/core/main/camel-core-2.10.0.redhat-60024.jar Change the file $JBOSS_HOME/modules/system/layers/soa/org/apache/camel/core/main/modules.xml so it references the correct jar name: <resources> <resource-root path="camel-core-2.10.0.redhat-60024.jar"/> </resources> CREATOR: Rick Wagner DATE: 04/17/2014
Story Points: ---
Clone Of:
: 1085902 (view as bug list) Environment:
Last Closed: 2014-04-17 14:56:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1085902    
Attachments:
Description Flags
Example to reproduce the issue
none
how to apply SwitchYard Message Validator
none
patched camel-core jar (2.10.0.redhat-60024+CAMEL-7036)
none
patched camel-core jar (2.10.0.redhat-60024+CAMEL-7036+CAMEL-6538)
none
Packaged patch for BZ1066350, this artifact for upload to CSP none

Description Yusuf Koer 2014-02-18 09:35:33 UTC
Created attachment 864434 [details]
Example to reproduce the issue

Description of problem:
We see an exception when we validate against an xml schema which again imports other xsd's. This happens with a fresh FSW 6.0.0 GA installation.
But replacing camel-core-2.10.0.redhat-60024.jar by camel-core-2.10.0.jar solves the problem.


Here an example snippet from a route definition:
.choice()
    .when()
        .xpath("count(/canonical:CanonicalMessage)", CanonicalConstants.NAMESPACE)
        // validate incoming canonical message
        .to("validator:canonical.xsd")
        .to("switchyard://EbsOutCanonicalService")
    .when()
        .xpath("count(/ebs:EbsMessage)", EbsConstants.NAMESPACE)
        // validate incoming ebs message
        .to("validator:ebs.xsd")
        .to("switchyard://EbsOutEndsystemService")
    .end();

Here the the exception which we see


How reproducible:

Steps to Reproduce:
1.Deploy attached quickstart on FSW 6.0.0.GA

Actual results:
We see following exception:
18:08:39,507 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.unit."switchyard-quickstart-camel-xsd.jar".SwitchYardService: org.jboss.msc.service.StartException in service jboss.deployment.unit."switchyard-quickstart-camel-xsd.jar".SwitchYardService: org.switchyard.SwitchYardException: Failed to create route route1 at: >>> To[validator:canonical.xsd] <<< in route: Route[[From[switchyard://JavaDSL]] -> [Log[Message received ... because of Failed to resolve endpoint: validator://canonical.xsd due to: null
	at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:80)
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
	at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: org.switchyard.SwitchYardException: Failed to create route route1 at: >>> To[validator:canonical.xsd] <<< in route: Route[[From[switchyard://JavaDSL]] -> [Log[Message received ... because of Failed to resolve endpoint: validator://canonical.xsd due to: null
	at org.switchyard.component.camel.deploy.CamelActivator.handleImplementation(CamelActivator.java:103)
	at org.switchyard.component.camel.deploy.CamelActivator.activateService(CamelActivator.java:75)
	at org.switchyard.deploy.internal.Deployment.deployImplementations(Deployment.java:546)
	at org.switchyard.deploy.internal.Deployment.start(Deployment.java:144)
	at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:101)
	at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:73)
	... 5 more
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[validator:canonical.xsd] <<< in route: Route[[From[switchyard://JavaDSL]] -> [Log[Message received ... because of Failed to resolve endpoint: validator://canonical.xsd due to: null
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:879)
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:172)
	at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:731)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1803)
	at org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:675)
	at org.switchyard.component.camel.deploy.CamelActivator.handleImplementation(CamelActivator.java:95)
	... 10 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: validator://canonical.xsd due to: null
	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:488)
	at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:61)
	at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:187)
	at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)
	at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)
	at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:61)
	at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:55)
	at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:461)
	at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:179)
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:876)
	... 15 more
Caused by: java.lang.NullPointerException
	at org.apache.camel.component.validator.DefaultLSResourceResolver.resolveResource(DefaultLSResourceResolver.java:73)
	at org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
	at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
	at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
	at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:627) [rt.jar:1.7.0_51]
	at __redirected.__SchemaFactory.newSchema(__SchemaFactory.java:168) [jboss-modules.jar:1.2.2.Final-redhat-1]
	at org.apache.camel.processor.validation.ValidatingProcessor.createSchema(ValidatingProcessor.java:279)
	at org.apache.camel.processor.validation.ValidatingProcessor.loadSchema(ValidatingProcessor.java:143)
	at org.apache.camel.component.validator.ValidatorComponent.createEndpoint(ValidatorComponent.java:55)
	at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:91)
	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:469)
	... 24 more


Additional info:
JDK:
java version "1.7.0_51"
OpenJDK Runtime Environment (fedora-2.4.4.1.fc19-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

Comment 1 Yusuf Koer 2014-03-26 09:50:12 UTC
Hi Keith,

our release date comes closer. When do you think can we expect a fix for the camel xsd validation bug? I don't wanna go live with the replaced jar, since we don't know if it has other negative impacts.

Thanks
Yusuf

Comment 2 Rick Wagner 2014-04-07 15:23:18 UTC
Hi Yusuf,

GSS will begin helping with this case.  Thanks for the reproducer.

Please let us know if 8 weeks out is too late to help you.  (This BZ is now part of a scheduled 'Roll up' patch we will release around that timeframe.)   If we need to, we may be able to produce a "One off" fix faster but this will be a temporary measure.

Please let us know more about your timing needs.

Regards,

Rick

Comment 3 Tomohisa Igarashi 2014-04-08 01:07:20 UTC
Created attachment 883805 [details]
how to apply SwitchYard Message Validator

Hi Yusuf,

I found a bug around camel validator on camel JIRA:
https://issues.apache.org/jira/browse/CAMEL-6013

So I tried it against SwitchYard 2.0.0-SNAPSHOT which is using camel-2.12.2, but then I hit another existing bug:
https://issues.apache.org/jira/browse/CAMEL-7036

For now, I would recommend using SwitchYard Message Validator instead. Please take a look at attached diff and following doc.
https://docs.jboss.org/author/display/SWITCHYARD/XML+Validator

Comment 4 Tomohisa Igarashi 2014-04-08 02:47:03 UTC
Apparently we hit this bug which is fixed at camel-2.10.7:
https://issues.apache.org/jira/browse/CAMEL-6538
https://github.com/apache/camel/commit/9ac5de93ed794aeb38f499c471967b316adb21d4

Yusuf, could you try if you can get around this bug with specifying "classpath:" prefix?
>>>
    .validator("validator:classpath:canonical.xsd")
<<<

I'll try it as well once I setup FSW6 (now downloading...).

Comment 5 Tomohisa Igarashi 2014-04-08 07:24:21 UTC
I tried the "classpath:"prefix and didn't work. But instead of that, it was deployed successfully if I just created src/main/resources/xsd directory and moved all XSDs into the directory. Then adjust the JavaDSLBuilder like this:
.validator("validator:xsd/canonical.xsd")

Basically this CAMEL-6538 is caused by the XSD which is located at root directory of the classpath, so creating directory and move into it avoid the issue.

But then, I hit CAMEL-7036 again, even on FSW6.0:
https://issues.apache.org/jira/browse/CAMEL-7036

So I think the patch we really need to get this work is a backport for the CAMEL-7036.
https://github.com/apache/camel/commit/300ecab4fa18c8988335a393eeb0b2302ff6f1c9

Comment 6 Tomohisa Igarashi 2014-04-08 09:32:21 UTC
Created attachment 883939 [details]
patched camel-core jar (2.10.0.redhat-60024+CAMEL-7036)

OK, confirmed it works once I cherry-pick the commit for CAMEL-7036 (c14b4f380d20f29330cc30ac6e2c49f04c23d256) on top of camel-2.10.0.redhat-60024

Please don't forget to move all XSDs into subdirectory before trying.

Comment 7 Yusuf Koer 2014-04-08 15:12:00 UTC
Hey Rick,

our initial release plan was
QA:    2014/04/14
Stage: 2014/04/28
Prod:  2014/05/05

But we found an issue in A-MQ 6.0 which will be fixed in 6.1. I think we will postpone the push by 2 weeks when we assume that A-MQ will released during Red Hat Summit.

Thanks
Yusuf

Comment 8 Rick Wagner 2014-04-08 15:30:31 UTC
Hi Yusuf,

Great, thanks for that information.

Did we ever get a proper support ticket opened up (with Dave Carmichael)?
The reason I ask is that we can use that to monitor and track this BZ.  (BZs don't carry reminders, SLAs, etc.  So they can slip through the cracks more easily.)  Please try to get one of those so we can better track this, we'll have some coordination to do.

About that coordination..... it seems the timeframe will dictate that we should adapt Tomo's fix (referenced above) as a One-off.  (Because it will be available in time, the Roll up that will include this fix will not.)  So I think what we'll need to do:

- Get QE to validate Tomo's fix
- Have you validate Tomo's fix
- If both of these check out, you go with that fix for your Roll out
- Later, we add this to FSW Roll up 2 (as described earlier)
- Roll up 2 goes through QE, with other patches
- When Roll up 2 is available, you can upgrade to it and no longer have a One-off environment

Please consider, offer your thoughts.  It is going to be best if you can upgrade when the 'official' patch is available with the Roll up, else you won't have a way to consume CVEs, other bug fixes, etc.

I'll start talking to QE about checking this as a One-off.

Thanks,

Rick

Comment 9 Yusuf Koer 2014-04-08 16:06:40 UTC
Rick,

I will definitely review Tomo's fix. One thing I don't like is the requirement to move all xsd's into a subdirectory. This would require some changes on our side.
Why can we not apply same logic from camel-core-2.10.0.jar where it is working like expected?

Btw, I created the case
https://access.redhat.com/support/cases/01066931/

Thanks
Yusuf

Comment 11 Tomohisa Igarashi 2014-04-09 00:49:14 UTC
Created attachment 884298 [details]
patched camel-core jar (2.10.0.redhat-60024+CAMEL-7036+CAMEL-6538)

Attaching a patched camel-core jar - cherry-picked following two commits on top of 2.10.0.redhat-60024. I tested it with the testcase and it works without moving XSDs into subdir.

==========================================================
commit 3dfaa78468819ca340c5943db5d932d05b598aa2
Author: Claus Ibsen <davsclaus>
Date:   Thu Jul 11 10:55:12 2013 +0200

    CAMEL-6538: NPE in validator component if no classpath prefix

commit 81a66870d70c993e2de00b9bf14f562c7caf080e
Author: Willem Jiang <willem.jiang>
Date:   Wed Dec 4 12:51:50 2013 +0800

    CAMEL-7036 Fixed the issue of Camel XSD validation not working with apache xerces

Comment 12 Yusuf Koer 2014-04-09 10:15:48 UTC
Hi Tomo,

your latest library with CAMEL-6538 and CAMEL-7036 works.
Will this fix be part of FSW 6.1?

Thank you very much for your help and for your support!
Yusuf

Comment 14 Yusuf Koer 2014-04-09 16:06:19 UTC
Thanks a lot Rick

Comment 15 Len DiMaggio 2014-04-09 18:17:03 UTC
Rick - you asked that FSW QE run Camel regression tests on this - to verify that no new issues are introduced - will you re-open the bz and assign it to QE?

Comment 16 Rick Wagner 2014-04-09 18:26:20 UTC
Thanks for that note, Len.

As requested:  Please validate Camel through regular regression tests.  Our customer (Yusuf) has validated the broken use case, so we are confident this part works.  Let's just give it a look to make sure nothing else about Camel broke with this one.

Thanks!

Rick

P.S.  For posterity:  This BZ has been cloned to another BZ which will push this change into FSW 6.1.  So Yusuf (and other customers) can upgrade at 6.1 time to get away from a "One off" environment.

Comment 17 Kevin Howell 2014-04-14 17:47:04 UTC
We applied the patched jar (2.10.0.redhat-60024+CAMEL-7036+CAMEL-6538) and are now seeing further issues.

We have a camel DSL route where we take a domain object, marshall it, and then validate that it conforms to an XSD. This is now throwing an exception:
java.lang.IllegalArgumentException: Source parameter of type 'javax.xml.transform.stax.StAXSource' is not accepted by this validator.
         at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
         at org.apache.camel.processor.validation.ValidatingProcessor.process(ValidatingProcessor.java:126)
         at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:101)
         at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)
         at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
         at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
         at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122)
         at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)
         at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)

This issue does not exist in the camel-core-2.10.0.jar mentioned above.

The attached test case could be modified to reproduce (simply unmarshall/marshall before validation).

Thanks,
Kevin

Comment 18 Tomohisa Igarashi 2014-04-14 23:30:00 UTC
According to this JIRA, StAXSource is not supported on EAP6.1:
https://issues.jboss.org/browse/JBEAP-41

Could you just use StreamSource or something instead of StAXSource?

Comment 19 Tomohisa Igarashi 2014-04-14 23:45:34 UTC
Maybe adding <convertBodyTo type="javax.xml.transform.stream.StreamSource"/> right before the validator. Please provide a reproducer if it doesn't work.

Comment 20 ppecka 2014-04-16 12:39:11 UTC
this BZ was reproduced and verified to be fixed, tested with QA integration testsuite - PASS (no regression seen)

a9a774354cb3ce7598d883b0c970d2c6 camel-core-2.10.0.redhat-60024.jar

Comment 22 Rick Wagner 2014-04-17 14:10:30 UTC
Created attachment 887197 [details]
Packaged patch for BZ1066350, this artifact for upload to CSP

Comment 23 Rick Wagner 2014-04-17 14:12:41 UTC
Please upload this patch to the CSP.  Thank you!