【问题标题】:'File' access is not allowed due to restriction set by the accessExternalSchema property由于 accessExternalSchema 属性设置的限制,不允许“文件”访问
【发布时间】:2019-09-10 04:54:45
【问题描述】:

我正在尝试使用 XSD 验证 xml 有效负载,其中这个 XSD 指的是其他的,而另一个指的是其他的。类似于嵌套引用。

当我在Validate Schema 路径中包含所有.xsd 时,我仍然得到:

根异常堆栈跟踪:org.xml.sax.SAXParseException; schema_reference:无法读取架构文档“MPProduct.xsd”, 因为由于设置的限制,不允许“文件”访问 访问ExternalSchema 属性。 om.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:306) 在 com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4160) 在 com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaFatalError(XSDHandler.java:4135) 在 com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2172) 在 com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:2100) 在 com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:1104) 在 com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:623) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:613) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:572) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:538) 在 com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:255) 在 org.mule.module.xml.internal.operation.SchemaValidatorOperation$2.create(SchemaValidatorOperation.java:142) 在 org.mule.module.xml.internal.operation.SchemaValidatorOperation$2.create(SchemaValidatorOperation.java:132) 在 org.apache.commons.pool2.BasePooledObjectFactory.makeObject(BasePooledObjectFactory.java:58) 在 org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:888) 在 org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:432)

请问有什么解决这个问题的建议吗?

我尝试在本地运行时在 VM 参数中添加 -Djavax.xml.accessExternalSchema=all,但它仍然保持不变

<flow name="mytestingFlow" doc:id="4efe5074-da20-4164-843a-06ca9a2a9979" >
        <http:listener doc:name="Listener" doc:id="74f4f199-00cb-460d-b72f-df3497f26e6a" config-ref="HTTP_Listener_config" path="/service/path/one"/>
        <set-payload value="#[&quot;&lt;MPItemFeed xmlns=\&quot;http://walmart.com/\&quot;&gt;&lt;MPItemFeedHeader&gt;&lt;version&gt;3.2&lt;/version&gt;&lt;/MPItemFeedHeader&gt;&lt;MPItem&gt;&lt;processMode&gt;CREATE&lt;/processMode&gt;&lt;sku&gt;10145802&lt;/sku&gt;&lt;productIdentifiers&gt;&lt;productIdentifier&gt;&lt;productIdType&gt;UPC&lt;/productIdType&gt;&lt;productId&gt;123456789123&lt;/productId&gt;&lt;/productIdentifier&gt;&lt;/productIdentifiers&gt;&lt;MPProduct&gt;&lt;SkuUpdate&gt;NO&lt;/SkuUpdate&gt;&lt;msrp&gt;183.99&lt;/msrp&gt;&lt;productName&gt;CARQUEST Platinum Professional Ceramic Brake Pads - Front (4-Pad Set)&lt;/productName&gt;&lt;ProductIdUpdate&gt;YES&lt;/ProductIdUpdate&gt;&lt;category&gt;&lt;Vehicle&gt;&lt;VehiclePartsAndAccessories&gt;&lt;shortDescription&gt;Ceramic Brake Pads - Front (4-Pad Set)&lt;/shortDescription&gt;&lt;keyFeatures&gt;&lt;keyFeaturesValue&gt;Premium brake pad underlayer reduces vibration for silent braking Industry leading number of application specific formulations for maximum performance Revolutionary burnishing compound strip allows for proper break-in of pads and rotors.&lt;/keyFeaturesValue&gt;&lt;/keyFeatures&gt;&lt;brand&gt;CARQUEST Platinum Professional&lt;/brand&gt;&lt;manufacturer&gt;CARQUEST Platinum Professional&lt;/manufacturer&gt;&lt;manufacturerPartNumber&gt;PXD1210H&lt;/manufacturerPartNumber&gt;&lt;mainImageUrl&gt;http://pdfifsvcprd.corp.advancestores.com/assets/epc50x50/std.lang.all/1012147531.jpg&lt;/mainImageUrl&gt;&lt;isProp65WarningRequired&gt;Yes&lt;/isProp65WarningRequired&gt;&lt;prop65WarningText&gt;cancer and reproductive&lt;/prop65WarningText&gt;&lt;hasWarranty&gt;YES&lt;/hasWarranty&gt;&lt;warrantyText&gt;LIMITED LIFETIME REPLACEMENT&lt;/warrantyText&gt;&lt;/VehiclePartsAndAccessories&gt;&lt;/Vehicle&gt;&lt;/category&gt;&lt;/MPProduct&gt;&lt;MPOffer&gt;&lt;price&gt;182.99&lt;/price&gt;&lt;ShippingWeight&gt;&lt;measure&gt;4&lt;/measure&gt;&lt;unit&gt;lb&lt;/unit&gt;&lt;/ShippingWeight&gt;&lt;ProductTaxCode&gt;2038710&lt;/ProductTaxCode&gt;&lt;/MPOffer&gt;&lt;/MPItem&gt;&lt;MPItem&gt;&lt;processMode&gt;CREATE&lt;/processMode&gt;&lt;sku&gt;11395545&lt;/sku&gt;&lt;productIdentifiers&gt;&lt;productIdentifier&gt;&lt;productIdType&gt;UPC&lt;/productIdType&gt;&lt;productId&gt;123456789123&lt;/productId&gt;&lt;/productIdentifier&gt;&lt;/productIdentifiers&gt;&lt;MPProduct&gt;&lt;SkuUpdate&gt;NO&lt;/SkuUpdate&gt;&lt;msrp&gt;183.99&lt;/msrp&gt;&lt;productName&gt;CARQUEST Platinum Brake Rotor - Front&lt;/productName&gt;&lt;ProductIdUpdate&gt;YES&lt;/ProductIdUpdate&gt;&lt;category&gt;&lt;Vehicle&gt;&lt;VehiclePartsAndAccessories&gt;&lt;shortDescription&gt;Brake Rotor - Front&lt;/shortDescription&gt;&lt;keyFeatures&gt;&lt;keyFeaturesValue&gt;Engineered to withstand 120 hours of salt spray testing Manufactured to exacting quality and dimensional specifications for Superior Stopping Power Exceeds ISO manufacturing guidelines (International Organization for Standardization)&lt;/keyFeaturesValue&gt;&lt;/keyFeatures&gt;&lt;brand&gt;CARQUEST Platinum&lt;/brand&gt;&lt;manufacturer&gt;CARQUEST Platinum&lt;/manufacturer&gt;&lt;manufacturerPartNumber&gt;YH145232P&lt;/manufacturerPartNumber&gt;&lt;mainImageUrl&gt;http://pdfifsvcprd.corp.advancestores.com/assets/epc50x50/std.lang.all/1017931756.jpg&lt;/mainImageUrl&gt;&lt;isProp65WarningRequired&gt;No&lt;/isProp65WarningRequired&gt;&lt;prop65WarningText/&gt;&lt;hasWarranty&gt;YES&lt;/hasWarranty&gt;&lt;warrantyText&gt;2 YR REPLACEMENT IF DEFECTIVE&lt;/warrantyText&gt;&lt;/VehiclePartsAndAccessories&gt;&lt;/Vehicle&gt;&lt;/category&gt;&lt;/MPProduct&gt;&lt;MPOffer&gt;&lt;price&gt;182.99&lt;/price&gt;&lt;ShippingWeight&gt;&lt;measure&gt;4&lt;/measure&gt;&lt;unit&gt;lb&lt;/unit&gt;&lt;/ShippingWeight&gt;&lt;ProductTaxCode&gt;2038710&lt;/ProductTaxCode&gt;&lt;/MPOffer&gt;&lt;/MPItem&gt;&lt;MPItem&gt;&lt;processMode&gt;CREATE&lt;/processMode&gt;&lt;sku&gt;10556036&lt;/sku&gt;&lt;productIdentifiers&gt;&lt;productIdentifier&gt;&lt;productIdType&gt;UPC&lt;/productIdType&gt;&lt;productId&gt;123456789123&lt;/productId&gt;&lt;/productIdentifier&gt;&lt;/productIdentifiers&gt;&lt;MPProduct&gt;&lt;SkuUpdate&gt;NO&lt;/SkuUpdate&gt;&lt;msrp&gt;183.99&lt;/msrp&gt;&lt;productName&gt;CARQUEST Premium Lube Element with Lid&lt;/productName&gt;&lt;ProductIdUpdate&gt;YES&lt;/ProductIdUpdate&gt;&lt;category&gt;&lt;Vehicle&gt;&lt;VehiclePartsAndAccessories&gt;&lt;shortDescription&gt;Lube Element with Lid&lt;/shortDescription&gt;&lt;keyFeatures&gt;&lt;keyFeaturesValue&gt;Environmental cartridge lube filter High efficiency and durable cellulose/synthetic blended media for longer drain intervals Silicone anti-drain back valve has 3X the durability verses nitrile for engine start-up protection&lt;/keyFeaturesValue&gt;&lt;/keyFeatures&gt;&lt;brand&gt;CARQUEST Premium&lt;/brand&gt;&lt;manufacturer&gt;CARQUEST Premium&lt;/manufacturer&gt;&lt;manufacturerPartNumber&gt;84312&lt;/manufacturerPartNumber&gt;&lt;mainImageUrl&gt;http://pdfifsvcprd.corp.advancestores.com/assets/epc50x50/std.lang.all/1015772990.jpg&lt;/mainImageUrl&gt;&lt;isProp65WarningRequired&gt;Yes&lt;/isProp65WarningRequired&gt;&lt;prop65WarningText&gt;cancer and reproductive&lt;/prop65WarningText&gt;&lt;hasWarranty&gt;YES&lt;/hasWarranty&gt;&lt;warrantyText&gt;REPLACE OR REFUND AT MGR DISCRETION&lt;/warrantyText&gt;&lt;/VehiclePartsAndAccessories&gt;&lt;/Vehicle&gt;&lt;/category&gt;&lt;/MPProduct&gt;&lt;MPOffer&gt;&lt;price&gt;182.99&lt;/price&gt;&lt;ShippingWeight&gt;&lt;measure&gt;4&lt;/measure&gt;&lt;unit&gt;lb&lt;/unit&gt;&lt;/ShippingWeight&gt;&lt;ProductTaxCode&gt;2038710&lt;/ProductTaxCode&gt;&lt;/MPOffer&gt;&lt;/MPItem&gt;&lt;MPItem&gt;&lt;processMode&gt;CREATE&lt;/processMode&gt;&lt;sku&gt;20471798&lt;/sku&gt;&lt;productIdentifiers&gt;&lt;productIdentifier&gt;&lt;productIdType&gt;UPC&lt;/productIdType&gt;&lt;productId&gt;123456789123&lt;/productId&gt;&lt;/productIdentifier&gt;&lt;/productIdentifiers&gt;&lt;MPProduct&gt;&lt;SkuUpdate&gt;NO&lt;/SkuUpdate&gt;&lt;msrp&gt;183.99&lt;/msrp&gt;&lt;productName&gt;Denso Air-Fuel Ratio Sensor 4 Wire, Direct Fit, Heated, Wire Length: 10.63&lt;/productName&gt;&lt;ProductIdUpdate&gt;YES&lt;/ProductIdUpdate&gt;&lt;category&gt;&lt;Vehicle&gt;&lt;VehiclePartsAndAccessories&gt;&lt;shortDescription&gt;Air-Fuel Ratio Sensor 4 Wire, Direct Fit, Heated, Wire Length: 10.63&lt;/shortDescription&gt;&lt;keyFeatures&gt;&lt;keyFeaturesValue&gt;Specifically designed to meet the increasing demands of today's engines 100% checked for high temperature signal output, air tightness, continuity, and heat resistance for optimal efficiency and performance Double protection cover helps maintain proper unit temperature for quicker response times, which is critical to your vehicle's fuel efficiency&lt;/keyFeaturesValue&gt;&lt;/keyFeatures&gt;&lt;brand&gt;Denso&lt;/brand&gt;&lt;manufacturer&gt;Denso&lt;/manufacturer&gt;&lt;manufacturerPartNumber&gt;234-9001&lt;/manufacturerPartNumber&gt;&lt;mainImageUrl&gt;http://pdfifsvcprd.corp.advancestores.com/assets/epc50x50/std.lang.all/524891.jpg&lt;/mainImageUrl&gt;&lt;isProp65WarningRequired&gt;No&lt;/isProp65WarningRequired&gt;&lt;prop65WarningText/&gt;&lt;hasWarranty&gt;YES&lt;/hasWarranty&gt;&lt;warrantyText&gt;1 YR REPLACEMENT IF DEFECTIVE&lt;/warrantyText&gt;&lt;/VehiclePartsAndAccessories&gt;&lt;/Vehicle&gt;&lt;/category&gt;&lt;/MPProduct&gt;&lt;MPOffer&gt;&lt;price&gt;182.99&lt;/price&gt;&lt;ShippingWeight&gt;&lt;measure&gt;4&lt;/measure&gt;&lt;unit&gt;lb&lt;/unit&gt;&lt;/ShippingWeight&gt;&lt;ProductTaxCode&gt;2038710&lt;/ProductTaxCode&gt;&lt;/MPOffer&gt;&lt;/MPItem&gt;&lt;/MPItemFeed&gt;
&quot;]" doc:name="Set Payload" doc:id="b16a5f07-fa58-4c36-837a-3533eecdcccd" mimeType="application/xml"/>
        <ee:transform doc:name="Transform Message" doc:id="a6d22ddb-1e3a-4519-a22f-41987f9b5049" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/xml  
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <xml-module:validate-schema doc:name="Validate schema" doc:id="c5dbaef9-d4f3-4aeb-b15a-516aa0eb2479" schemas="Animal.xsd,ArtAndCraftCategory.xsd,Baby.xsd,CarriersAndAccessoriesCategory.xsd,ClothingCategory.xsd,Electronics.xsd,FoodAndBeverageCategory.xsd,FootwearCategory.xsd,FurnitureCategory.xsd,GardenAndPatioCategory.xsd,HealthAndBeauty.xsd,Home.xsd,JewelryCategory.xsd,Media.xsd,MPCommons.xsd,MPItem.xsd,MPItemFeed.xsd,MPItemFeedHeader.xsd,MPOffer.xsd,MPProduct.xsd,MusicalInstrument.xsd,OccasionAndSeasonal.xsd,OfficeCategory.xsd,OtherCategory.xsd,Photography.xsd,SportAndRecreation.xsd,ToolsAndHardware.xsd,ToysCategory.xsd,Vehicle.xsd,WatchesCategory.xsd" config-ref="XML_Config"/>
        <logger level="INFO" doc:name="Logger" doc:id="a74dbf49-d111-4eb3-84c3-598845ecaf48" />
    </flow>

【问题讨论】:

    标签: xml-validation mule4


    【解决方案1】:

    XSD 文件所在的位置是什么?需要为XSD指定路径here

    读取文件是个问题。读取 mUnit 输入文件时也面临类似的问题。在这些情况下,文件可以读取为:getResourceAsStringgetResourceAsStream

    This 应该会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多