You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Jakarta JAXB遭遇ClassNotFoundException的排查与解决

Tomcat 10.1下JAXB XML导入导出的ClassNotFoundException问题解决

项目基础信息

  • 开发场景:SQL数据库管理交互Web界面,基于Servlet + Jakarta Servlet JSTL
  • 服务器版本:TomCat v10.1
  • 目标功能:通过JAXB实现数据的XML格式导入导出

初始报错信息

执行代码JAXBContext context = JAXBContext.newInstance(ExportVeiculo.class);时触发异常:

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

已确认问题源于依赖配置,尝试过将相关JAR包放入项目WEB-INF/lib目录及服务器lib目录,均未解决。

依赖补充与错误排查步骤

  1. 移除jaxb-impl并添加jaxb-core-3.0.1.jar后,出现新的类缺失错误:
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
  1. 补充istack-commons-runtime-3.0.1.jar后,仍存在类缺失问题:
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

最终解决方案

添加Jakarta Activation API 2.0.1依赖后,问题彻底解决。


内容的提问来源于stack exchange,提问作者Letho123

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 17:39:52