8

I'm migrating from java 8 to 11 and I'm having a problem launching the springboot server:

nested exception is java.lang.NoClassDefFoundError: javax / jws / WebService.

I used in my pom.xml:

maven-compiler 3.8.0
cxf.version 3.3.0-SNAPSHOT

the compilation goes well but not the start of the server thank you

Graham
  • 7,431
  • 18
  • 59
  • 84
Issam Lemlih
  • 91
  • 1
  • 1
  • 3

2 Answers2

7

JAX-WS is the library that provides javax.jws.WebService and related classes. It was supplied as part of Java SE 8 through 10, but removed for Java 11. You will need to get that library as an external dependency.

If you are using maven, you should be able to add a dependency on com.sun.xml.ws:jaxws-ri:<current-version> in your pom.xml:

<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-ri</artifactId>
        <version>2.3.1</version>
    </dependency>
</dependencies>
Andrew Janke
  • 23,508
  • 5
  • 56
  • 85
  • thank you , I Have another problème now : Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath. - with linked exception: [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory] – Issam Lemlih Dec 11 '18 at 17:37
  • my jaxb & jaxws dependencies are : javax.xml.bind:jaxbapi:2.3.1 org.glassfish.jaxb:jaxb-runtime:2.3.1 com.sun.xml.bind:jaxb-core2.3.1 com.sun.xml.bind:jaxb-impl:2.3.1 com.sun.xml.ws:jaxws-ri:2.3.0 javax.annotation:javax.annotation-api:1.3.1 – Issam Lemlih Dec 11 '18 at 17:43
  • 1
    The original version of your Dependency might be incomplete. I had to add `pom` because it isn't a jar in the repository. – Mutant Bob Apr 25 '19 at 17:18
  • 1
    Hmm. I don't think so. That `pom` seems to be more for the `` section (https://stackoverflow.com/questions/11778276/what-is-the-difference-between-pom-type-dependency-with-scope-import-and-wit). And I've got a HelloWorld example running with this dependency specification as is. Typically, Maven dependencies don't require specifying a ``. – Andrew Janke Apr 25 '19 at 23:46
  • 1
    You can also use jaxws-rt instead. See https://stackoverflow.com/questions/5401358/whats-the-difference-between-jaxws-ri-and-jaxws-rt then you don't need the type:pom. – BitfulByte Oct 22 '19 at 08:00
3

If Andrew's answer doesn't work, this fixed it for me:

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.3.3</version>
</dependency>

That's the runtime dependency instead of reference implementation - see this question for more info

NicolaeS
  • 423
  • 2
  • 7