[ 
https://issues.apache.org/jira/browse/CXF-2083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712270#action_12712270
 ] 

Todd Michael commented on CXF-2083:
-----------------------------------

I can't speak to this problem directly, but I can say that the code in the 
XmlBeansSchemaInitializer.getSchema() method (the method throwing your 
exception) is not currently capable of resolving external XML schema references 
(i.e. http:// as opposed to relative locations in the local file system).  The 
code is simply resolving all references locally using the following code:

InputStream ins = sts.getSourceAsStream(file);

If any of your XML schema <import> statements in any of your references schemas 
contain URL/URI external references, this method will fail in exactly the same 
way as you have seen in your attached stack trace.  In addition, even local 
file resources can fail to resolve if you haven't correctly specified the 
relative file locations of each import in every schema file you are deploying 
and managing locally.

I think this could be fixed fairly easily by simply making use of an XML entity 
resolver in the getSchema() method and making sure that you deploy every 
required XML schema document locally.  Please let me know if you have made any 
other progress on this issue, or if your are still experiencing this problem.  

> XMLBeans - XmlBeansSchemaInitializer can't handle xs:import
> -----------------------------------------------------------
>
>                 Key: CXF-2083
>                 URL: https://issues.apache.org/jira/browse/CXF-2083
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.1.4
>         Environment: Java 1.5, Spring 2.5, CXF 2.1.4, Any OS.
>            Reporter: Knut Ivar Skogland
>            Assignee: Willem Jiang
>         Attachments: CXFTestXmlBeansXSD.rar
>
>
> Background: 
> I have a Xfire project which I'm porting to CXF. Using the Document-First 
> approach and using XMLBeans. We have one xsd that imports other xsd's for 
> each "domain". Every "domain" xsd contains requests and responses which 
> imports datatypes from underlaying schemas with different namespaces.
> This works with JAXB (And Xfire with XMLBeans), but not with CXF and XMLBeans.
> I have simplified a test project.
> The structure is like this;
> PublishedFacade.xsd              -- imports sum.xsd
>          | ---- sum.xsd                -- contains request and responses. 
> Imports types.xsd.
>                      | ---- types.xsd  -- contains complextypes and 
> simpletypes for XMLObject validation
> PublishedFacade.xsd:
> --------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://cxftest.com/webservicetest/ws/test";
>             xmlns:tns="http://cxftest.com/webservicetest/ws/test";
>             xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>             xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
>             elementFormDefault="qualified">
>     <xsd:import namespace="http://cxftest.com/webservicetest/ws/test/sum"; 
> schemaLocation="sum/sum.xsd"/>
> </xsd:schema>
> --------------------------------------------------------------------------
> sum.xsd:
> --------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://cxftest.com/webservicetest/ws/test/sum";
>             xmlns:tns="http://cxftest.com/webservicetest/ws/test/sum";
>             xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>             xmlns:types ="http://cxftest.com/webservicetest/ws/test/sum/types";
>             xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
>             elementFormDefault="qualified">
>     <xsd:import 
> namespace="http://cxftest.com/webservicetest/ws/test/sum/types"; 
> schemaLocation="types/types.xsd"/>
>     <xsd:element name="testServiceRequest" type="types:TestServiceRequest" />
>     <xsd:element name="testServiceResponse" type="types:TestServiceResponse" 
> />
> </xsd:schema>
> --------------------------------------------------------------------------
> types.xsd:
> --------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema 
> targetNamespace="http://cxftest.com/webservicetest/ws/test/sum/types";
>             xmlns:tns="http://cxftest.com/webservicetest/ws/test/sum/types";
>             xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>             xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
>             elementFormDefault="qualified">
>     <xsd:complexType name="TestServiceRequest">
>         <xsd:sequence>
>             <xsd:element name="number1" type="xsd:int" minOccurs="0" 
> nillable="true" />
>             <xsd:element name="number2" type="tns:nummer2" minOccurs="1" 
> nillable="false" />
>         </xsd:sequence>
>     </xsd:complexType>
>     <xsd:complexType name="TestServiceResponse">
>         <xsd:sequence>
>             <xsd:element name="sum" type="xsd:int" minOccurs="1" 
> nillable="false" />
>         </xsd:sequence>
>     </xsd:complexType>
>     <xsd:simpleType name="nummer2">
>         <xsd:restriction base="xsd:int">
>             <xsd:minInclusive value="1"/>
>             <xsd:maxInclusive value="20"/>
>         </xsd:restriction>
>     </xsd:simpleType>
> </xsd:schema>
> --------------------------------------------------------------------------
> Generate xmlbeans objects with xmlbeans-maven-plugin.
> When deploying; I get this stack;
> ----------------------------------------------------------
> 13:05:32,193 [] ERROR [org.springframework.web.context.ContextLoader] Context 
> initialization failed
> org.springframework.beans.factory.BeanCreationException: Error creating bean 
> with name 'testservice': Invocation of init method failed; nested exception 
> is javax.xml.ws.WebServiceException: java.lang.RuntimeException: Failed to 
> find schema for: sum/sum.xsd
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1175)
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
> at 
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
> at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
> at 
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
> at 
> org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
> at 
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
> at 
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
> at 
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
> at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> at org.apache.catalina.core.StandardService.start(StandardService.java:448)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
> Caused by: javax.xml.ws.WebServiceException: java.lang.RuntimeException: 
> Failed to find schema for: sum/sum.xsd
> at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:268)
> at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:202)
> at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:397)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242)
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
> at 
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
> ... 25 more
> Caused by: java.lang.RuntimeException: Failed to find schema for: sum/sum.xsd
> at 
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.getSchema(XmlBeansSchemaInitializer.java:148)
> at 
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.mapClass(XmlBeansSchemaInitializer.java:200)
> at 
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.begin(XmlBeansSchemaInitializer.java:170)
> at 
> org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceModelVisitor.java:97)
> at 
> org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.java:74)
> at 
> org.apache.cxf.xmlbeans.XmlBeansDataBinding.initialize(XmlBeansDataBinding.java:102)
> at 
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:371)
> at 
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:525)
> at 
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:422)
> at 
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:190)
> at 
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:164)
> at 
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:100)
> at 
> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:117)
> at 
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:168)
> at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:339)
> at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:252)
> ... 34 more
> Caused by: java.lang.RuntimeException: Failed to find schema for: 
> types/types.xsd
> at 
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.getSchema(XmlBeansSchemaInitializer.java:148)
> at 
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.getSchema(XmlBeansSchemaInitializer.java:135)
> ... 49 more
> Caused by: java.lang.IllegalArgumentException: InputStream cannot be null
> at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:94)
> at org.apache.cxf.helpers.XMLUtils.parse(XMLUtils.java:136)
> at 
> org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer.getSchema(XmlBeansSchemaInitializer.java:129)
> ... 50 more
> ----------------------------------------------------------
> There were a similar error using xs:include 
> (https://issues.apache.org/jira/browse/CXF-1700), but I can't use include as 
> the wsdl will be different when the namespaces changes. My wsdl's should not 
> change.
> Project that "explains" the issue has been attatched.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to