|
|
|
This (NPE in WsGenTask) happens to me occassionally too... Just FYI: in general with a "bad" WSDL XFire typically launches a NPE, and one (I) then need XML Spy and/or Eclipse WTP to try to find out what is wrong with it. There are probably be different things that can cause NPEs here...
For example, just today I got the following stacktrace under v1.1.2: [Maven/Ant stuff ommited] Not a big issue, as we are usually able to move on, but as somebody filed an issue, I thought our observation may be of interest. Another one, if this is of interest, this happens with v1.1.2 is there is no wsdl:input in WSDL:
Caused by: java.lang.NullPointerException Idea: If the WSDL was validated against WSDL's (and also the schema's) XML schema, maybe that would catch some problems and show clearer errors? Or maybe wsdl4j can actually do that, or some other form of validation, already? – Just an idea how to make this area more "robust" - short of having to put lot's of if (abc=null) all over the WSDLServiceBuilder and in the (Apache not XFire!) SchemaBuilder.
I observed the same issue with another toolkit (axis2).
Reference: http://marc.theaimsgroup.com/ (search for "xsd:include", message title "[Axis2] WSDL2Java does not handle xsd:include correctly") I am willing to switch to xfire if this issue gets solved! The problem is with the following construct found in the OTA file "OTA_SimpleTypes.xsd": The base mentioned above is defined a few lines later in the same file: Note that the shema does not use a fully qualified name --> base="UpperCase..". In most other restriction base types of the same file, a fully qualified name is used: In this case, base="xs:string". Looking at the code where the NPE happens, we see that a fully qualified name is mandatory: if (temp.length != 1) { namespace = temp[0]; } //let it crash because its mean being refered The comment in this code clearly states that a fully qualified name is required when defining a restriction base type definition for a simple type. Now, what is the good behavior in this situation? To summarize, from a WSDL definition using OTA shema, we have a xsd:include of a message like "OTA_HotelAvailRQ.xsd". This message includes basic types like "OTA_SimpleTypes.xsd" which defines UpperCaseAlphaLength1to2 which is used as a base to define "PaymentCardCodeType". We need to follow the namespace definitions closely in this scenario in order to understand what the code should have done instead of the NPE. Our understanding must also be valid agains the W3C specification... Let's start with the WSDL (I'm using the files.ZIP attachement): The default namespace is therefore "http://www.opentravel.org/OTA/2003/05" Now, in file OTA_HotelAvailRQ.xsd: <xs:schema xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.opentravel.org/OTA/2003/05" elementFormDefault="qualified" version="1.005" id="OTA2006A"> Again, the default namespace is "http://www.opentravel.org/OTA/2003/05", this is also the target namespace. Finally, look at the OTA_SimpleTypes.xsd file: <?xml version="1.0" encoding="UTF-8"?> Here, only the xs namespace is defined for internal references like xs:string. The real question is: Which namespaces should be known and valid when dealing with this inclusion coming from OTA_HotelAvailRQ? In the OTA messages, the high level messages use the targetNamespace to set the namespace. By design, all more primitive types are in separated schemas which are This looks fine and seems logical. Also, the W3C specification documents this practice. Specifically, the documents- , that is <schema> information items. The - XML Schema- corresponding to <schema> contains not only the of all the - XML Schemas- corresponding to any <include>d schema <include>ing schema document, or (b) no targetNamespace at all, in targetNamespace. The included schema will be in the OTA's RQ or RS namespace according What is the next step? What do you think? I've been able to reproduce the issue in XmlSchema independently of xfire (see attached files).
To reproduce, get XmlSchema (I used 1.0.3, same behavior as 1.0.1) and unzip IncludeTest.java in the tests directory, unzip the xsd files in test-resources and run the unit tests. One test case is ok: the one which defines a default namespace in the included file. So, this is clearly an issue for the XmlSchema team, so why write this here in this log? I would like that the current owner of this log reproduces the issue like I did to confirm the conclusion so far. Then, we'll (I?) open the log on XmlSchema's jira. Sample xsd from the attachement: <schema targetNamespace="http://soapinterop.org/xsd" includeAux= <xs:simpleType name="PaymentCardCodeType"> <xs:simpleType name="UpperCaseAlphaLength1to2"> </schema> This example is ok, remove line <<xmlns="http://www.w3.org/2001/XMLSchema">> in the file above and it will fail. It seems to me that this declaration should be considered implicit and this should be handled in ShemaBuilder.handleSimpleType I run the tests that you sent and you are perfectly right.
The one with default namespace works fine and the one without namespace returns a NullPointerException. The output is: It is clear then that the problem is in XMLSchema. Thank you very much to all the people that helped. Thank you for confirming the issue.
I created the entry in XmlSchema's Jira: http://issues.apache.org/jira/browse/WSCOMMONS-87 Thanks! I will try to get this fixed in the xml schema project.
Hum, I should had a closer look at the existing issues:
http://issues.apache.org/jira/browse/WSCOMMONS-78 Is about the same issue and seems fixed. There is an XmlSchema build here that you can use until the next XmlSchema release (in a couple days):
http://people.apache.org/repository/org.apache.ws.commons/jars/XmlSchema-SNAPSHOT.jar Closing this issue as it seems to be fixed now. Thanks. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The stack trace of the exception is the following:
/home/jmanuel/src/SpecsOTA/build.xml:35: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at org.codehaus.xfire.gen.WsGenTask.execute(WsGenTask.java:48)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1926)
at org.apache.ws.commons.schema.SchemaBuilder.handleImport(SchemaBuilder.java:1712)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:130)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:273)
at org.codehaus.xfire.wsdl11.parser.WSDLServiceBuilder.visit(WSDLServiceBuilder.java:351)
at org.codehaus.xfire.wsdl11.parser.WSDLServiceBuilder.build(WSDLServiceBuilder.java:180)
at org.codehaus.xfire.gen.Wsdl11Generator.generate(Wsdl11Generator.java:102)
at org.codehaus.xfire.gen.WsGenTask.execute(WsGenTask.java:44)
... 12 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1926)
at org.apache.ws.commons.schema.SchemaBuilder.handleInclude(SchemaBuilder.java:1750)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:125)
at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:52)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:268)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:230)
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1924)
... 19 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1926)
at org.apache.ws.commons.schema.SchemaBuilder.handleInclude(SchemaBuilder.java:1750)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:125)
at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:52)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:268)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:230)
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1924)
... 25 more
Caused by: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.handleSimpleType(SchemaBuilder.java:347)
at org.apache.ws.commons.schema.SchemaBuilder.handleSimpleType(SchemaBuilder.java:481)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:108)
at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:52)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:268)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:230)
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1924)
... 31 more
— Nested Exception —
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1926)
at org.apache.ws.commons.schema.SchemaBuilder.handleImport(SchemaBuilder.java:1712)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:130)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:273)
at org.codehaus.xfire.wsdl11.parser.WSDLServiceBuilder.visit(WSDLServiceBuilder.java:351)
at org.codehaus.xfire.wsdl11.parser.WSDLServiceBuilder.build(WSDLServiceBuilder.java:180)
at org.codehaus.xfire.gen.Wsdl11Generator.generate(Wsdl11Generator.java:102)
at org.codehaus.xfire.gen.WsGenTask.execute(WsGenTask.java:44)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1926)
at org.apache.ws.commons.schema.SchemaBuilder.handleInclude(SchemaBuilder.java:1750)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:125)
at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:52)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:268)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:230)
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1924)
... 19 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1926)
at org.apache.ws.commons.schema.SchemaBuilder.handleInclude(SchemaBuilder.java:1750)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:125)
at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:52)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:268)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:230)
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1924)
... 25 more
Caused by: java.lang.NullPointerException
at org.apache.ws.commons.schema.SchemaBuilder.handleSimpleType(SchemaBuilder.java:347)
at org.apache.ws.commons.schema.SchemaBuilder.handleSimpleType(SchemaBuilder.java:481)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:108)
at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:52)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:268)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:230)
at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1924)
... 31 more