David M. Karr
David M. Karr

Reputation: 15225

maven-jaxb2-plugin reports prefix is already bound, only in Eclipse

I'm trying to debug a Maven-based Spring Boot project. It makes SOAP calls, and it uses the maven-jaxb2-plugin artifact in group org.jvnet.jaxb2.maven2 to generate Java classes from WSDL files.

When I build this project from the mvn command line, it builds fine.

However, when I load it into Eclipse (2019-03), I see errors like this in the Problems view:

org.apache.maven.plugin.PluginExecutionException: Execution addrole of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3:generate failed: Prefix '' is already bound to ''
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$7(MavenImpl.java:1342)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1341)
    at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
    at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:173)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:116)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:106)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:87)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:201)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
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:567)
    at com.sun.xml.txw2.ContainerElement.invoke(ContainerElement.java:134)
    at com.sun.proxy.$Proxy60._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_2.XJC22Mojo.generateCode(XJC22Mojo.java:66)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:41)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:473)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:316)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    ... 30 more

The plugin is referenced in the pom like this:

    <plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.13.3</version>
    <executions>
        <execution>
            <id>suggestHandle</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <schemaDirectory>${project.basedir}/src/main/resources/schemas/mpssoap</schemaDirectory>
                <schemaIncludes>
                    <include>*.wsdl</include>
                </schemaIncludes>
                <clearOutputDir>false</clearOutputDir>
            </configuration>
        </execution>

This is followed by a dozen or so more execution elements, pointing to different subdirectories of src/main/resources.

I already installed the "m2e connector for jaxb" plugin, but that didn't appear to make any difference.

What else could be going wrong here?

I'm using Eclipse 2019-03 and v0.13.3 of the maven-jaxb2-plugin artifact.

Upvotes: 2

Views: 2844

Answers (2)

Yuri.Detochkin
Yuri.Detochkin

Reputation: 1

I had this issue too with Maven 3.5.2 The Maven version on server is not up to me to change.

So I changed plugin version to 0.15.1 in pom.xml and it worked:

            <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.15.1</version>
            <executions>

Upvotes: 0

Romano
Romano

Reputation: 455

Can you check what is the version of your JDK used by Eclipse against the one you use in your command line? I got a similar problem using Zulu 11, with jaxb2 as well. Since this might be related to https://github.com/eclipse-ee4j/jaxb-ri/issues/1220 try to make you Eclipse JDK compliance to match the one you are using in your console.

EDIT: Moving from Maven 3.6.0 to 3.6.3 fixed the problem on my end, hopefully it will also be the case for you.

Upvotes: 4

Related Questions