[ 
https://issues.apache.org/jira/browse/WSCOMMONS-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ajith Harshana Ranabahu resolved WSCOMMONS-173.
-----------------------------------------------

    Resolution: Won't Fix
      Assignee: Ajith Harshana Ranabahu

I am marking this issue as resolved since it is not very clear whether it is 
actually a problem with Axis2 or XMLSchema. 

> targetNamespace attribute on schema tag seems to be required when using import
> ------------------------------------------------------------------------------
>
>                 Key: WSCOMMONS-173
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-173
>             Project: WS-Commons
>          Issue Type: Bug
>          Components: XmlSchema
>         Environment: Windows XP, JRE 1.5.0_06
>            Reporter: simon clare
>            Assignee: Ajith Harshana Ranabahu
>         Attachments: Request_Logon.xsd, service.wsdl
>
>
> Apologies if this is:
> A: not a very clear bug report.  I should really recreate this in isolation, 
> but I'm too idle. 
> B: Actually nothing in fact to do with WS-Commons XMLSchema
> I'm using Axis2's org.apache.axis2.wsdl.WSDL2Java which reads a WSDL in, and 
> does a bunch of fun generation stuff. My WSDL defines a document literal 
> style Web Service which includes external XSD's. Those XSD's then internally 
> include a whole bunch of other XSD's. Under the hood Axis2 is using 
> org.apache.ws.commons.schema.XmlSchemaCollection.read to read the inlined 
> schemas. 
> The chunk of code which does this is in 
> org.apache.axis2.description.WSDLToAxisServiceBuilder:
>     protected XmlSchema getXMLSchema(Element element, String baseUri) {
>         XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
>         if (baseUri != null) schemaCollection.setBaseUri(baseUri);
>         if (customResolver != null) {
>             schemaCollection.setSchemaResolver(customResolver);
>         }
>         return schemaCollection.read(element);
>     }
> As far as I can work out "element" is the root DOM node of the imported XSD. 
> XMLSchema then falls over with a NullPointerException as follows:
> log4j:WARN No appenders could be found for logger 
> (org.apache.axis2.description.WSDL11ToAxisServiceBuilder).
> log4j:WARN Please initialize the log4j system properly.
> Exception in thread "main" 
> org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL
>       at 
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:112)
>       at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:32)
>       at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:21)
> Caused by: org.apache.axis2.AxisFault: java.lang.NullPointerException; nested 
> exception is: 
>       java.lang.RuntimeException: java.lang.NullPointerException
>       at 
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:250)
>       at 
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:103)
>       ... 2 more
> Caused by: java.lang.RuntimeException: java.lang.NullPointerException
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1808)
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1820)
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.handleImport(SchemaBuilder.java:1552)
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:156)
>       at 
> org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:315)
>       at 
> org.apache.axis2.description.WSDLToAxisServiceBuilder.getXMLSchema(WSDLToAxisServiceBuilder.java:132)
>       at 
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.copyExtensibleElements(WSDL11ToAxisServiceBuilder.java:1719)
>       at 
> org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:214)
>       ... 3 more
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.ws.commons.schema.SchemaBuilder$1.validate(SchemaBuilder.java:1534)
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.setNamespaceAttributes(SchemaBuilder.java:283)
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:78)
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:67)
>       at 
> org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:325)
>       at 
> org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:272)
>       at 
> org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1806)
> When the schema is initially created via the constructor  
> XmlSchema(XmlSchemaCollection parent) it does nothing with the attribute 
> syntacticalTargetNamespace. The code in SchemaBuilder.setNamespaceAttributes  
> wants to set the namespace if its there. If its not there then ignores it, as 
> its expecting there not to be a validator class variable in the XMLSchema 
> object if there is no namespace. However, somehow in this instance of the 
> Schema a validator has been created (not quite got to how yet, as it's a fun 
> little anonymous inner class and my head hurts).
> Basically SchemaBuilder$TargetNamespaceValidator.validate:
> public void validate(XmlSchema pSchema) {
>                 final boolean valid;
>                 if (isEmpty(uri)) {
>                     valid = isEmpty(pSchema.syntacticalTargetNamespace);
>                 } else {
>                     valid = pSchema.syntacticalTargetNamespace.equals(uri);
>                 }
> finds uri not to be empty (not sure which of the many possible URI's this is) 
> and assumes you must have a syntacticalTargetNamespace to call equals on. 
> Unfortunately its null.
> Is this:
> A: An Axis2 problem (they using your API wrongly)?
> B: A bug in XMLSchema
> C: An incorrectly defined XSD trying to be imported.
> It seems to work OK if I set my imported xsd's to have a targetNamespace. 
> However, I think the XSD spec says they don't *have* to have one. In any case 
> the rather unpleasant Null Pointer might not be the best way to deal with any 
> error condition. 

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to