java.lang.IllegalArgumentException: Prefix '' is already bound to '' on jdk11
See original GitHub issueThe goal of com.oracle.weblogic:weblogic-maven-plugin:12.3.1-0-0:ws-jwsc is failed on jdk11 with following exception.
Caused by: java.lang.IllegalArgumentException: Prefix '' is already bound to ''
at com.sun.xml.txw2.StartTag.addNamespaceDecl (StartTag.java:191)
at com.sun.xml.txw2.ContainerElement._namespace (ContainerElement.java:333)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at com.sun.xml.txw2.ContainerElement.invoke (ContainerElement.java:134)
at com.sun.proxy.$Proxy41._namespace (Unknown Source)
at com.sun.xml.ws.wsdl.writer.WSDLGenerator.generateDocument (WSDLGenerator.java:394)
at com.sun.xml.ws.wsdl.writer.WSDLGenerator.doGeneration (WSDLGenerator.java:316)
at weblogic.wsee.tools.jws.jaxws.JAXWSProcessor.generateWsdl (JAXWSProcessor.java:335)
at weblogic.wsee.tools.jws.jaxws.JAXWSProcessor.generateWsdl (JAXWSProcessor.java:242)
at weblogic.wsee.tools.jws.jaxws.JAXWSProcessor.finish (JAXWSProcessor.java:227)
at weblogic.wsee.tools.jws.process.CompositeProcessor.finish (CompositeProcessor.java:59)
at weblogic.wsee.tools.jws.build.JwsCompiler.buildWebServices (JwsCompiler.java:546)
at weblogic.wsee.tools.jws.build.JwsCompiler.compile (JwsCompiler.java:503)
at weblogic.wsee.tools.anttasks.JwsModule.generate (JwsModule.java:442)
at weblogic.wsee.tools.anttasks.JwsModule.build (JwsModule.java:306)
at weblogic.wsee.tools.anttasks.JwscTask.execute (JwscTask.java:242)
at weblogic.tools.maven.plugins.webservices.JwscMojo.execute (JwscMojo.java:156)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo
(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
...
And the issue is caused by the following code:
package com.sun.xml.ws.wsdl.writer //jaxws 2.3.0.2v and jaxb 2.3.0.1v
public class WSDLGenerator {
...
private void generateDocument(XmlSerializer serviceStream, XmlSerializer portStream) {
serviceDefinitions = TXW.create(Definitions.class, serviceStream); //Line#1
serviceDefinitions._namespace(WSDL_NAMESPACE, "");//WSDL_PREFIX); //Line#2
serviceDefinitions._namespace(XSD_NAMESPACE, XSD_PREFIX);
serviceDefinitions.targetNamespace(model.getServiceQName().getNamespaceURI());
serviceDefinitions._namespace(model.getServiceQName().getNamespaceURI(), TNS_PREFIX);
...
}
...
}
The empty namespace can be bound to the empty prefix in implementation of jaxb. If empty namespace is bound to the empty prefix in Line#1, the IllegalArgumentException will be thrown. Because WSDL_NAMESPACE (http://schemas.xmlsoap.org/wsdl/) also attempts to bind to the empty prefix in Line#2.
This issue only happens on jdk9 and later versions.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
Looks to be caused by maven classloading in the context of maven plugin goal execution. Incorrect usage of empty prefix is caused by incorrect empty namespace URI which in turn is caused by not loading package-info.class which contains the URI declaration. For example see here I have filed a https://github.com/codehaus-plexus/plexus-classworlds/issues/3
I’ve tested with maven 3.6.1 and now org.codehaus.mojo:jaxb2-maven-plugin works as I hoped it would. Thanks for pinpointing this issue which ate a good bunch of hours.