java - ClassNotFoundException using JAXB with Jakarta, what am i doing wrong? - Stack Overflow

admin2025-04-17  4

I currently working on a project to create a web interface to manage and interact with an SQL Database, i am using Jakarta.servlet.jstl in my servlets and TomCat v10.1, and i am now trying to use JAXB to add the ability to export and import data in xml format, the problem is that i get the following error

SEVERE: Servlet.service() for servlet [Servlets.VeiculoServlet] in context with path [/ExamplePath] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader

on the line

JAXBContext context = JAXBContext.newInstance(ExportVeiculo.class);

I am very confident that this is related to my library setup in my project, here it is

My project Build Path ClassPath Libraries

And this is how i import them, in the servlet that is throwing the error

I have also tried adding all the JAR file to the servers lib folder, but this does not seem to have any effect.

Thank you in advance, and if any more information is needed, i am happy to provide.

Edit 1:

After some feedback in the comments,I added jaxb-core-3.0.1.jar and removed jaxb-impl,

i got a diferent error then, in the same line

SEVERE: Servlet.service() for servlet [Servlets.VeiculoServlet] in context with path [/ExamplePath] threw exception [Servlet execution threw an exception] with root cause java.lang.ClassNotFoundException: com.sun.istack.Pool

I added Istack-Commons-Runtime-3.0.1.jar , and i am now getting a diferent error in the same line

SEVERE: Servlet.service() for servlet [Servlets.VeiculoServlet] in context with path [/ExamplePath] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: jakarta.activation.DataSource

Edit 2: I installed Jakarta Activation API » 2.0.1 , and now everything is working.

I currently working on a project to create a web interface to manage and interact with an SQL Database, i am using Jakarta.servlet.jstl in my servlets and TomCat v10.1, and i am now trying to use JAXB to add the ability to export and import data in xml format, the problem is that i get the following error

SEVERE: Servlet.service() for servlet [Servlets.VeiculoServlet] in context with path [/ExamplePath] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader

on the line

JAXBContext context = JAXBContext.newInstance(ExportVeiculo.class);

I am very confident that this is related to my library setup in my project, here it is

My project Build Path ClassPath Libraries

And this is how i import them, in the servlet that is throwing the error

I have also tried adding all the JAR file to the servers lib folder, but this does not seem to have any effect.

Thank you in advance, and if any more information is needed, i am happy to provide.

Edit 1:

After some feedback in the comments,I added jaxb-core-3.0.1.jar and removed jaxb-impl,

i got a diferent error then, in the same line

SEVERE: Servlet.service() for servlet [Servlets.VeiculoServlet] in context with path [/ExamplePath] threw exception [Servlet execution threw an exception] with root cause java.lang.ClassNotFoundException: com.sun.istack.Pool

I added Istack-Commons-Runtime-3.0.1.jar , and i am now getting a diferent error in the same line

SEVERE: Servlet.service() for servlet [Servlets.VeiculoServlet] in context with path [/ExamplePath] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: jakarta.activation.DataSource

Edit 2: I installed Jakarta Activation API » 2.0.1 , and now everything is working.

Share Improve this question edited Feb 1 at 14:38 Letho123 asked Feb 1 at 12:25 Letho123Letho123 1291 gold badge2 silver badges11 bronze badges 6
  • 1 Download Jaxb Core Jar org.glassfish.jaxb » jaxb-core » 3.0.1(repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-core/3.0.1/…) – life888888 Commented Feb 1 at 12:42
  • I have tried both of these suggetions and i now get a diferent error SEVERE: Servlet.service() for servlet [Servlets.VeiculoServlet] in context with path [/ExamplePath] threw exception [Servlet execution threw an exception] with root cause java.lang.ClassNotFoundException: com.sun.istack.Pool – Letho123 Commented Feb 1 at 13:19
  • 1 java.lang.NoClassDefFoundError: com/sun/istack/Pool(stackoverflow.com/questions/60389012/…) – life888888 Commented Feb 1 at 13:32
  • 1 read jaxb-core-3.0.1.pom(repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-core/3.0.1/…) dependencies: <dependency> <groupId>com.sun.istack</groupId> <artifactId>istack-commons-runtime</artifactId> </dependency> – life888888 Commented Feb 1 at 13:35
  • 1 Do not use images for text information. Paste the actual code. – aled Commented Feb 1 at 17:17
 |  Show 1 more comment

1 Answer 1

Reset to default 0

I Solved my problem by installing jaxb-core-3.0.1.jar , and all its dependencies, linked in the comments of the post

转载请注明原文地址:http://anycun.com/QandA/1744828498a88186.html