相关文章推荐
跑龙套的蚂蚁  ·  DataAdapter 的參數 - ...·  1 月前    · 
虚心的梨子  ·  mac ...·  8 月前    · 
激动的莲藕  ·  JavaScript ...·  1 年前    · 
俊逸的匕首  ·  c++11 - Move or swap ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Spring boot - JAxbException(jakarta.xml.bind.JAXBException: Implementation of jakarta xml binding-api not found on module path or classpath)

Ask Question

java version I have a maven project (version 1.8) and java version (1.8). I have a task where I have used eclipse moxy ( jaxb implementation) for creating xmls. I also have the jaxb.properties file in the package where the classes are present.

jakarta.xml.bind.JAXBContextFactory=org.eclipse.persistence.jaxb.JAXBContextFactory

The pom of the project looks like below:

<build>
        <plugins>
            <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>
        </plugins>
</build>
<dependencies>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.20</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>2.0.0-alpha4</version>
        </dependency>
        <dependency> 
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>3.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>3.0.0</version>
        </dependency>
    </dependencies>

This project is integrated into a microservice, as an artifact and the controller in the microservice does some unmarshalling and marshalling. The pom of the microservice looks like below:

<dependencies>
        <dependency>
            <groupId>XXX</groupId>
            <artifactId>ProjectX</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>3.0.0</version>
        </dependency>
<dependencies>

This works perfectly fine in the IDE. I can see the result i expect. however, when I go by the terminal and do a mvn packageand build the project, a jar is created in the target folder.

When I execute the jar, I get the following error:

jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath. -with linked exception: [java.lang.classNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]

Please let me know what I am doing wrong here? A beginner here

There are some tips on how to solve this problem mkyong.com/java/… But it shouldn't occur on Java 8. If you recently changed your environment variables they could be not updated in your terminal Check the version of Java in your terminal with java -version – absence Dec 8, 2021 at 8:21

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.