You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "David (Jira)" <ji...@apache.org> on 2021/11/19 16:49:00 UTC

[jira] [Created] (AXIS2-6014) Error while generating java code from WSDL

David created AXIS2-6014:
----------------------------

             Summary: Error while generating java code from WSDL
                 Key: AXIS2-6014
                 URL: https://issues.apache.org/jira/browse/AXIS2-6014
             Project: Axis2
          Issue Type: Bug
    Affects Versions: 1.8.0
         Environment: Axis 1.8.0 (adb databinding)
OpenJDK 17
Maven 3.8.1
Eclipse 2021-09
            Reporter: David


I'm trying to generate java code from a WSDL file with Axis 1.8.0 and ADB databinding. When running axis2-wsdl2code:wsdl2code via maven, I get the following error:
{noformat}
[WARNING] Exception occurred while trying to pretty print file C:\Dev\ServiceStub.java
com.google.googlejavaformat.java.FormatterException: 848:107: error: integer number too large: 9223372036854775807
    at com.google.googlejavaformat.java.FormatterException.fromJavacDiagnostics(FormatterException.java:50)
    at com.google.googlejavaformat.java.Formatter.format(Formatter.java:151)
    at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:258)
    at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:234)
    at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:202)
    at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:189)
    at org.apache.axis2.util.PrettyPrinter.prettify(PrettyPrinter.java:46)
    at org.apache.axis2.wsdl.codegen.extension.JavaPrettyPrinterExtension.prettifyFile(JavaPrettyPrinterExtension.java:43)
    at org.apache.axis2.wsdl.codegen.extension.AbstractPrettyPrinterExtension.prettify(AbstractPrettyPrinterExtension.java:54)
    at org.apache.axis2.wsdl.codegen.extension.AbstractPrettyPrinterExtension.engage(AbstractPrettyPrinterExtension.java:37)
    at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:157)
    at org.apache.axis2.maven2.wsdl2code.AbstractWSDL2CodeMojo.execute(AbstractWSDL2CodeMojo.java:362)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
{noformat}
Even though the build ends with success, the ServiceStub.java file does not appear among the generated files.

When using Axis 1.7.9, ServiceStub is generated but does not compile. Here are the faulty lines:
{code:java}
            if ((1 <= java.lang.String.valueOf(param).length()) &&
                    (java.lang.String.valueOf(param).length() <= 9223372036854775807) &&
                    (org.apache.axis2.databinding.utils.ConverterUtil.convertToString(
                        param).matches("(\\s*\\S\\s*)+"))) {{code}
The compilation error being:
{noformat}
The literal 9223372036854775807 of type int is out of range{noformat}
I pinpointed the issue to this part of the WSDL:
{code:xml}
	<xs:simpleType name="nonEmptyString">
		<xs:restriction base="xs:string">
			<xs:minLength value="1"/>
			<xs:pattern value="(\s*\S\s*)+"/>
		</xs:restriction>
	</xs:simpleType>{code}
No maxLength is defined but during the code generation, Axis2 apparently assumes the max to be Long.MAX_VALUE without properly suffixing this value by L.

I managed to get around this issue by defining a maxLength <= Integer.MAX_VALUE in my wsdl but I'd rather not do that since this WSDL does not belong to us.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org