Signup/Sign In

[SOLVED] java.lang.ClassNotFoundException: javax.xml.ws.WebServiceFeature in Java 11

Posted in Tricks   LAST UPDATED: MAY 5, 2023

    For web applications created using JDK 1.8 or earlier versions, migrating to the new versions of Java can be a pain because a lot of core changes have been introduced starting Java 9.

    One such issue is ClassNotFoundException for JAXBException class [SOLVED] which is quite common and we have already covered its solution in one of our earlier posts.

    Once you have fixed the above issue by adding the jaxb-api, jaxb-impl, javax-activation-api and jaxb-core Jar files, there are chances that you must add one more JAR file which is specifically required for web applications.

    So, if you see the following exception in the error logs,

    Caused by: java.lang.ClassNotFoundException: javax.xml.ws.WebServiceFeature

    You will have to add the jaxws-api JAR file to your project.

    For Maven Projects:

    If you are using Maven for handling dependencies in your Java project, you will have to add the following additional dependency in your pom.xml file.

    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.3.1</version>
    </dependency>

    This will include the jaxws-api Jar file in your project when you will build your maven java project.

    For Gradle Projects:

    If you use Gradle to build your project, then add the following line to your build.gradle file,

    compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.1'
    

    For SBT Projects:

    If you use SBT build tool to compile and build your java project, then add the following line to your build file,

    libraryDependencies += "javax.xml.ws" % "jaxws-api" % "2.3.1"
    

    For IVY Projects:

    If you use ivy for building your java project, then add the following code line to your ivy.xml file:

    <dependency org="javax.xml.ws" name="jaxws-api" rev="2.3.1"/>
    

    Hope this solution helps you solve your problem.

    Conclusion

    The article discusses the solution to the ClassNotFoundException for javax.xml.ws.WebServiceFeature that Java developers may face while upgrading their web applications to Java versions after JDK 1.8. It suggests adding the jaxws-api JAR file as an additional dependency for web applications. The article provides solutions for different build tools, including Maven, Gradle, SBT, and Ivy, to add the jaxws-api JAR file.

    Frequently Asked Questions(FAQs)

    1. What is the no class found exception in Java?

    The NoClassDefFoundError exception is a common runtime exception in Java that occurs when the Java Virtual Machine (JVM) is unable to find a class that was present during compile time. This error can occur due to various reasons, such as missing or incorrect classpath settings, missing libraries or dependencies, or incorrect Java versions.

    2. What does binding provider do?

    A binding provider in Java is responsible for creating and configuring a JAXB (Java Architecture for XML Binding) context. JAXB is a Java API that enables Java objects to be mapped to and from XML documents. The binding provider reads a JAXB context configuration file and creates a context object that can be used to marshal Java objects to XML or unmarshal XML to Java objects. The binding provider is also responsible for configuring various options, such as validation, formatting, and error handling, that affect the behavior of the JAXB context.

    You may also like:

    About the author:
    I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight
    Tags:Java
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS