Closed gaoyan-gao closed 5 years ago
Several Maven plugins are suffering from this issue too:
https://artofcode.wordpress.com/2018/06/29/jaxb2-maven-plugin-2-4-and-java-10/
Looks like something is passing empty namespace URL (which causes it to be bound to empty prefix) before WSDL_NAMESPACE is added to default namespace / empty prefix.
Is there any reproducer for this issue?
I have found this empty namespace URL prefix to be a really problematic issue.
Basically, we need to perform XML transformations after a schemagen XSD generation to rename product schema files, and hence the tooling expects that the element (including its namespace) be constant.
I took the liberty of reporting this issue here as well: see #1223
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
@lennartj , i verified https://github.com/codehaus-plexus/plexus-classworlds/pull/4 fixed the schema xs:
prefix issue https://github.com/mojohaus/jaxb2-maven-plugin/issues/43
@bravehorsie , thanks for the fix, not sure when plexus-classworlds 2.5.3 will be released, yet, it requires a Maven release as well.
for now, i just built plexus-classworlds 2.5.3-SNAPSHOT on my local (with recent master branch), put the plexus-classworlds-2.5.3-SNAPSHOT.jar
to $MAVEN_HOME/boot/
, renamed existing plexus-classworlds-2.5.2.jar
to plexus-classworlds-2.5.2.jar.bak
plexus-classworlds 2.6.0 released you can either wait for Maven 3.6.1 or replace plexus-classworlds in /boot directory of any previous Maven release...
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.
Thanks for this. :)
The 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.