Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java-SpringWS-LoadingRelative包含在XSD文件中(Tomcat8)_Java_Spring_Tomcat_Soap_Xsd - Fatal编程技术网

Java-SpringWS-LoadingRelative包含在XSD文件中(Tomcat8)

Java-SpringWS-LoadingRelative包含在XSD文件中(Tomcat8),java,spring,tomcat,soap,xsd,Java,Spring,Tomcat,Soap,Xsd,我创建了一个Spring web服务,它使用以下代码从XSD文件集合创建动态WSDL: Resource[] schema = { new ClassPathResource( "schema/service/XCPD.SupportMaterials.v9/schema/HL7V3/NE2008/coreschemas/NarrativeBlock.xsd"), new ClassPathResource(

我创建了一个Spring web服务,它使用以下代码从XSD文件集合创建动态WSDL:

Resource[] schema = {
            new ClassPathResource(
                    "schema/service/XCPD.SupportMaterials.v9/schema/HL7V3/NE2008/coreschemas/NarrativeBlock.xsd"),
            new ClassPathResource(
                    "schema/service/XCPD.SupportMaterials.v9/schema/HL7V3/NE2008/coreschemas/datatypes-base.xsd"),
            new ClassPathResource(
                    "schema/service/XCPD.SupportMaterials.v9/schema/HL7V3/NE2008/coreschemas/infrastructureRoot.xsd"),
            new ClassPathResource(
                    "schema/service/XCPD.SupportMaterials.v9/schema/HL7V3/NE2008/multicacheschemas/PRPA_IN201305UV02.xsd"),
            new ClassPathResource(
                    "schema/service/XCPD.SupportMaterials.v9/schema/HL7V3/NE2008/multicacheschemas/PRPA_IN201306UV02.xsd"),
            new ClassPathResource(
                    "schema/service/XCPD.SupportMaterials.v9/schema/IHE/XCPD_PLQ.xsd"),
            new ClassPathResource(
                    "schema/service/XCPD.SupportMaterials.v9/schema/HL7V3/XCPD_PRPA.xsd") };
    CommonsXsdSchemaCollection collection = new CommonsXsdSchemaCollection(
            schema);
    collection.setInline(true);
    return collection;
用于创建动态WSDL的XSD文件包括其他各种模式文件,这些文件使用以下include语句:

<xs:include schemaLocation="../coreschemas/voc.xsd"/>
<xs:include schemaLocation="../coreschemas/datatypes.xsd"/>
Spring的URI解析器在路径前面加上“/”,即使引用的文件是相对路径(不是绝对路径),并且在导入模式时失败

应该注意的是,这个应用程序在Tomcat7上运行良好。当尝试将其迁移到Tomcat8时,会出现问题

Tomcat 8确实改变了web资源的加载方式

长话短说,有没有办法强制Spring让URI解析器正确处理相关文件?如果查看Spring使用的解析器(ClasspathUriResolver)上的“collectionBaseURI”属性,该值为null。有没有办法设置这个基本URI


编辑我可以通过将所有相对路径转换为模式的绝对路径来解决此问题。。。但是,我不想在数百个文件中应用此修复程序。

如果有人遇到此恼人的问题,则
ClasspathUriResolver
是罪魁祸首,在相对路径includes上预先加了一个“/”。我将其转换为使用默认URI解析器(在
org.apache.ws.commons.schema.Resolver.DefaultURIResolver
中),它在Tomcat8上运行良好,没有问题

CommonsXsdSchemaCollection collection = new CommonsXsdSchemaCollection(schema);
collection.setUriResolver(new DefaultURIResolver());
collection.setInline(true);
return collection;
CommonsXsdSchemaCollection collection = new CommonsXsdSchemaCollection(schema);
collection.setUriResolver(new DefaultURIResolver());
collection.setInline(true);
return collection;