[Solved] JAXBException: Implementation of JAXB-API has not been found on module path or classpath.

JAXBException is the root exception class for all the JAXB exceptions. Generally this exception occurred when the implemented code is not fulfill the pre-requisite for JAXB related dependencies.


JAXBException class having following constructors.

  • JAXBException(String msg): Construct exception with detail message..
  • JAXBException(String msg, String errorCode) : This construct exception with detail message with error code.
  • JAXBException(String msg, String errorCode, Throwable exception) : Construct detail message with error code and stacktrace of linked exception stacktrace.
  • JAXBException(String msg, Throwable exception) :Construct exception with detail message and stacktrace of linked exception.
  • JAXBException(Throwable exception) : Construct exception with stacktrace of linked exception.


This JAXBException occurred in your code because on runtime JAXB is not able to find JAXB-API related dependency.

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]
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:421)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
	at com.facingIssuesOnIT.domain.EmployeeJAXBTest.marshal(EmployeeJAXBTest.java:23)
	at com.facingIssuesOnIT.domain.EmployeeJAXBTest.main(EmployeeJAXBTest.java:15)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
	at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)
	... 5 more


To implement JAXB marshalling and unmarshalling in your application, you need to add following dependencies in you code. As above exception message explained “JAXB-API has not found in module or class path” this exception occurred when you forget to add JAXB-API dependency.





In this post , You learn about the JAXBException cases to occurred, different constructors and example to solve JAXB-API has not found in module or class path” JAXBException.

Let me know your thought to about this post.

Happy Learning !!!

One thought on “[Solved] JAXBException: Implementation of JAXB-API has not been found on module path or classpath.”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s