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

Code generation fails with "Prefix '' is already bound to ''" when episode generation is on on Java 9 #146

Closed
highsource opened this issue Apr 29, 2018 · 10 comments

Comments

@highsource
Copy link
Owner

On Java 9 with episode generation turned on, code generation fails:

[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb23-plugin:0.13.3-SNAPSHOT:generate (generate) on project maven-jaxb2-plugin-tests-java-9: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb23-plugin:0.13.3-SNAPSHOT:generate failed: Prefix '' is already bound to '' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb23-plugin:0.13.3-SNAPSHOT:generate (generate) on project maven-jaxb2-plugin-tests-java-9: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb23-plugin:0.13.3-SNAPSHOT:generate failed: Prefix '' is already bound to ''
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate of goal org.jvnet.jaxb2.maven2:maven-jaxb23-plugin:0.13.3-SNAPSHOT:generate failed: Prefix '' is already bound to ''
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 20 more
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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.sun.xml.txw2.ContainerElement.invoke(ContainerElement.java:134)
	at com.sun.proxy.$Proxy46._namespace(Unknown Source)
	at com.sun.tools.xjc.addon.episode.PluginImpl.run(PluginImpl.java:174)
	at com.sun.tools.xjc.model.Model.generateCode(Model.java:292)
	at org.jvnet.mjiip.v_2_3.XJC23Mojo.generateCode(XJC23Mojo.java:66)
	at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute(XJC23Mojo.java:41)
	at org.jvnet.mjiip.v_2_3.XJC23Mojo.doExecute(XJC23Mojo.java:28)
	at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:473)
	at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:317)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 21 more
@highsource
Copy link
Owner Author

I think this is actually a problem in the episode plugin. Which is part of XJC, not my code.

@nipafx
Copy link
Contributor

nipafx commented May 4, 2018

Just FYI: I just built the plugin from the 2.3 directory in the java-9 branch and I still get the same error for episode generation.

@highsource
Copy link
Owner Author

@nicolaiparlog Please build the whole thing in java-9 branch. Also please delete 0.13.3-SNAPSHOT from the local repo beforehand.

@davidbilge
Copy link

I have the same problem, but do not use episodes (at least not knowingly). Using maven-jaxb2-plugin version 0.13.3.

@nipafx
Copy link
Contributor

nipafx commented May 7, 2018

It's unclear to me why I have to build the entire project, but it works 😄 : I can now generate episode files (tested in this demo project).

@highsource
Copy link
Owner Author

@davidbilge If you did not explicitly configured episodes to false, then episode files will be generated by default.

@highsource
Copy link
Owner Author

@nicolaiparlog Great. It is necessary to rebuild the whole project since the fix is not in maven-jaxb23-plugin but in one of the core modules.

@highsource
Copy link
Owner Author

OK, I'll release the new version in the next days then. I don't see the need for extra pre-java9/post-java9 versions at the moment, So I'll risk releasing just one version.

@lhanson
Copy link

lhanson commented May 30, 2018

I'm experiencing the same issue, awaiting the next release. Thanks!

@mw84367
Copy link

mw84367 commented Nov 11, 2018

It seems that XJC has a bug. When I provide an additional dummy XML schema without the normal header
<xs:schema targetNamespace="my.namespace" elementFormDefault="qualified" xmlns="my.namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema">

,i.e. the "targetNamespace", "elementFormDefault" and "xmlns" attributes, the error is gone.

Thus one just need to add a dummy XSD file like
<xs:schema id="Dummy" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Dummy"> <xs:complexType> <xs:sequence> <xs:element name="test"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

and it works. :)

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

No branches or pull requests

5 participants