简体   繁体   中英

java.lang.NoClassDefFoundError:javax/xml/bind/JAXBContext

I'm using JDK 1.5 in my web project and using maven for compile.

I was facing this:

WebServiceException ("javax.xml.ws.WebServiceException: Provider com.sun.xml.ws.spi.ProviderImpl not found")

in my project. To fix that I used two approaches:

  • First, I add jaxws-rt-2.1.4 in my class path.(Also made entry in POM.xml)
  • Second, Added jar in jre/lib folder

But after this I am facing this:

java.lang.NoClassDefFoundError:javax/xml/bind/JAXBContext

Does anyone have any idea that could help me?

Adding a dependency on jaxb-impl should be sufficient, as this transitively depends on jaxb-api, which is the JAR containing the class it's complaining about. In Java 6, javax.xml.bind is part of the JRE by default so it would work out of the box there.

add this dependency to pom

    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.1</version>
    </dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM