[
https://issues.apache.org/jira/browse/AXIS2-4934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12984847#action_12984847
]
Carsten Pohl commented on AXIS2-4934:
-------------------------------------
I found the problem and wrote a patch.
In Version 1.5.4:
The problem is caused because the service.xml is not written correctly.
Basically a 0-byte long file will be created. Then the prettyfier tries to
prettify a 0-byte long file, which basically results in the reported errors.
The problem only shows in the services.xml because the ServiceXMLWriter behaves
differently to the FileWriter.java (both in the folder
/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/)
In FileWriter.parse only fileExists is checked. fileExists is basically set on
false, and because of the way the FileWriter.createOutFile(...) method works,
if isOverride is set, the fileExists parameter will not be changed and will
have its initial parameter of false.
services.xml file are written by ServiceXMLWriter.java in
ServiceXMLWriter.java.createOutFile the fileExists will be set to whether the
file actually exists. And the isOverride value is not taken into account.
A simple fix would be to add a line to the createOutFile Method:
public void createOutFile(String packageName, String fileName) throws
Exception {
outputFile =
org.apache.axis2.util.FileWriter.createClassFile(outputFileLocation,
packageName,
"services",
".xml");
//set the existing flag
fileExists = outputFile.exists();
if (!fileExists || this.isOverride) {
this.stream = new FileOutputStream(outputFile);
}
if (this.isOverride) fileExists=false;
}
But I would suggest to change the behaviour of .parse.
Who can I add the fix to the repository?
Regards,
Carsten Pohl
> wsdl2java returns error in second call if called twice with exact parameters
> ----------------------------------------------------------------------------
>
> Key: AXIS2-4934
> URL: https://issues.apache.org/jira/browse/AXIS2-4934
> Project: Axis2
> Issue Type: Bug
> Components: codegen
> Affects Versions: 1.5.4
> Environment: Tested on two machines 1. ubuntu system 2.6.26-2-xen-686
> 2. Ubuntu 9.10 2.6.31-22-generic
> Reporter: Carsten Pohl
>
> first machine:
> java version "1.6.0_12"
> Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
> Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
> second machine:
> java version "1.6.0_22"
> Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
> Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
> I downloaded the 1.5.4 binary distribution of axis2 from
> http://axis.apache.org/axis2/java/core/download.cgi
> I used a very simple WSDL file:
> <definitions name="HelloService"
> targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <message name="SayHelloRequest">
> <part name="firstName" type="xsd:string"/>
> </message>
> <message name="SayHelloResponse">
> <part name="greeting" type="xsd:string"/>
> </message>
> <portType name="Hello_PortType">
> <operation name="sayHello">
> <input message="tns:SayHelloRequest"/>
> <output message="tns:SayHelloResponse"/>
> </operation>
> </portType>
> <binding name="Hello_Binding" type="tns:Hello_PortType">
> <soap:binding style="rpc"
> transport="http://schemas.xmlsoap.org/soap/http"/>
> <operation name="sayHello">
> <soap:operation soapAction="sayHello"/>
> <input>
> <soap:body
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> namespace="urn:examples:helloservice"
> use="encoded"/>
> </input>
> <output>
> <soap:body
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> namespace="urn:examples:helloservice"
> use="encoded"/>
> </output>
> </operation>
> </binding>
> <service name="Hello_Service">
> <documentation>WSDL File for HelloService</documentation>
> <port binding="tns:Hello_Binding" name="Hello_Port">
> <soap:address location="http://www.examples.com/SayHello/"/>
> </port>
> </service>
> </definitions>
> If I use wsdl2java.sh on that file:
> /opt/axis2-1.5.4/bin/wsdl2java.sh -ssi -ap -or -ss -sd -o /tmp/bla --uri
> /tmp/thewsdlfile.wsdl
> and call it right again, I get a very strange error message:
> Using AXIS2_HOME: /opt/axis2-1.5.4/
> Using JAVA_HOME: /usr/lib/jvm/java-6-sun/
> Retrieving document at '/tmp/thwwsdlfile.wsdl'.
> [ERROR] Exception occurred while trying to pretty print file
> /tmp/bla/resources/services.xml
> ; Line#: -1; Column#: -1
> javax.xml.transform.TransformerException: Premature end of file.
> at
> org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java:780)
> at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:756)
> at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1284)
> at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1262)
> at
> org.apache.axis2.util.XMLPrettyPrinter.prettify(XMLPrettyPrinter.java:84)
> at
> org.apache.axis2.wsdl.codegen.extension.XMLPrettyPrinterExtension.prettifyFile(XMLPrettyPrinterExtension.java:39)
> at
> org.apache.axis2.wsdl.codegen.extension.AbstractPrettyPrinterExtension.prettify(AbstractPrettyPrinterExtension.java:53)
> at
> org.apache.axis2.wsdl.codegen.extension.AbstractPrettyPrinterExtension.engage(AbstractPrettyPrinterExtension.java:37)
> at
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:265)
> at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
> at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
> [ERROR] Exception occurred while trying to pretty print file
> /tmp/bla/resources/services.xml
> ; Line#: -1; Column#: -1
> javax.xml.transform.TransformerException: Premature end of file.
> at
> org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerImpl.java:780)
> at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:756)
> at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1284)
> at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1262)
> at
> org.apache.axis2.util.XMLPrettyPrinter.prettify(XMLPrettyPrinter.java:84)
> at
> org.apache.axis2.wsdl.codegen.extension.WSDLPrettyPrinterExtension.prettifyFile(WSDLPrettyPrinterExtension.java:33)
> at
> org.apache.axis2.wsdl.codegen.extension.AbstractPrettyPrinterExtension.prettify(AbstractPrettyPrinterExtension.java:53)
> at
> org.apache.axis2.wsdl.codegen.extension.AbstractPrettyPrinterExtension.engage(AbstractPrettyPrinterExtension.java:37)
> at
> org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:265)
> at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
> at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
--
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]