Skip to content

Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.5.0:xjc (xjc) on project: Prefix '' is already bound to '' #330

@UserBoi1

Description

@UserBoi1

Dear Mojohaus Team,

I am getting the following error upon building my project in Java 11:

[INFO] Created EpisodePath [XXXX/src/main/java/META-INF/JAXB]: true
[INFO] Ignored given or default xjbSources [XXXX/src/main/xjb], since it is not an existent file or directory.
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.5.0:xjc (xjc) on project XXXX: Prefix '' is already bound to ''

I have researched the issue thoroughly and implemented the suggestions I have found, but with no luck.

Considerations:

  • I am trying to maintain compatibility with Java 8 and Java 11, so that my app can be built to Java 8 and runnable on both 8 and 11.
  • I have adopted (JAXB 3.0.0) for this reason.
  • The jaxb2-maven-plugin versions available to me are: 1.5.0, 2.3.0, 2.3.1, and 2.5.0 (can't use 3.2.0 due to older Maven).

Please let me know if there is anything I can clarify.
Any help much appreciated.

POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<artifactId>XXXXXXXXXX</artifactId>
	<packaging>jar</packaging>
	<name>XXXXXXXXX</name>

	<parent>
		<groupId>XXXXXXXX</groupId>
		<artifactId>XXXXXXXX</artifactId>
		<version>XXXXXXXX</version>
	</parent>
	
	<properties>
		<jakarta.activation.version>2.0.0</jakarta.activation.version>
        <jakarta.xml.bind-api.version>3.0.0</jakarta.xml.bind-api.version>
    	<jaxb-impl.version>3.0.0</jaxb-impl.version>
    	<jaxb-runtime.version>3.0.0</jaxb-runtime.version>
    	<jaxb-xjc.version>3.0.0</jaxb-xjc.version>
    	<validation-api.version>2.0.1.Final</validation-api.version>
    	<hibernate-validator.version>6.2.5.Final</hibernate-validator.version>
	</properties>
	
	<dependencies>
		<dependency>
			<groupId>jakarta.xml.bind</groupId>
			<artifactId>jakarta.xml.bind-api</artifactId>
			<version>${jakarta.xml.bind-api.version}</version>
		</dependency>
		<dependency>
			<groupId>com.sun.xml.bind</groupId>
			<artifactId>jaxb-impl</artifactId>
			<scope>runtime</scope>
			<version>${jaxb-impl.version}</version>
		</dependency>
		<dependency>
			<groupId>org.glassfish.jaxb</groupId>
			<artifactId>jaxb-runtime</artifactId>
			<version>${jaxb-runtime.version}</version>
		</dependency>
        <dependency>
        	<groupId>javax.validation</groupId>
        	<artifactId>validation-api</artifactId>
        	<version>${validation-api.version}</version>
        </dependency>
        <dependency>
        	<groupId>org.hibernate.validator</groupId>
        	<artifactId>hibernate-validator</artifactId>
        	<version>${hibernate-validator.version}</version>
        </dependency>
	</dependencies>

	<build>
		<plugins>

			<!-- exclude xsd/xml from jar -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>*.xml</exclude>
						<exclude>*.xsd</exclude>
					</excludes>
				</configuration>
			</plugin>
			
			<plugin>
        		<artifactId>maven-remote-resources-plugin</artifactId>
        		<executions>
         			<execution>
            			<goals>
              				<goal>bundle</goal>
            			</goals>
          			</execution>
        		</executions>
        		<configuration>
          			<includes>
            			<include>**/*.xsd</include>
          			</includes>
        		</configuration>
      		</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			
			<plugin>
	            <groupId>org.codehaus.mojo</groupId>
	            <artifactId>jaxb2-maven-plugin</artifactId>
	            <version>2.5.0</version>
	            <executions>
	                <execution>
	                    <id>xjc</id>
	                    <goals>
	                        <goal>xjc</goal>
	                    </goals>
	                </execution>
	            </executions>
	            <configuration>
		            <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
						<packageName>XXXXXXXXX</packageName>
						<sources>
							<source>${project.basedir}/src/main/resources/TD.xsd</source>
						</sources>
						<!-- so we keep the src/main/java/.gitignore file which otherwise will 
							be deleted -->
						<clearOutputDir>false</clearOutputDir>
	            </configuration>
	            <dependencies>
	                <dependency>
	                	<groupId>com.sun.activation</groupId>
	                	<artifactId>jakarta.activation</artifactId>
	                	<version>${jakarta.activation.version}</version>
	                </dependency>
	                <dependency>
	                    <groupId>jakarta.xml.bind</groupId>
	                    <artifactId>jakarta.xml.bind-api</artifactId>
	                    <version>${jakarta.xml.bind-api.version}</version>
	                </dependency>
	                <dependency>
	                    <groupId>com.sun.xml.bind</groupId>
	                    <artifactId>jaxb-impl</artifactId>
	                    <version>${jaxb-impl.version}</version>
	                </dependency>
	                <dependency>
	                    <groupId>org.glassfish.jaxb</groupId>
	                    <artifactId>jaxb-xjc</artifactId>
	                    <version>${jaxb-xjc.version}</version>
	                </dependency>
	            </dependencies>
	        </plugin>
		</plugins>
	</build>
</project>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions