Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: Prefix '' is already bound to '' on jdk11 #1220

Closed
gaoyan-gao opened this issue Sep 27, 2018 · 8 comments
Closed

Comments

@gaoyan-gao
Copy link
Member

@gaoyan-gao gaoyan-gao commented Sep 27, 2018

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.

@bravehorsie
Copy link
Contributor

@bravehorsie bravehorsie commented Oct 5, 2018

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?

@lennartj
Copy link

@lennartj lennartj commented Oct 8, 2018

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

@bravehorsie
Copy link
Contributor

@bravehorsie bravehorsie commented Oct 9, 2018

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 codehaus-plexus/plexus-classworlds#3

@missedone
Copy link

@missedone missedone commented Dec 25, 2018

@lennartj , i verified codehaus-plexus/plexus-classworlds#4 fixed the schema xs: prefix issue mojohaus/jaxb2-maven-plugin#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

@hboutemy
Copy link

@hboutemy hboutemy commented Dec 30, 2018

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...

@gurgl
Copy link

@gurgl gurgl commented Apr 25, 2019

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.

@lennartj
Copy link

@lennartj lennartj commented Jul 7, 2019

Thanks for this. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.