gpt4 book ai didi

java - 尝试创建 JAXBContext 时出现未处理的异常 (Jaxb 2.0)

转载 作者:行者123 更新时间:2023-11-29 04:04:43 26 4
gpt4 key购买 nike

我正在尝试让代码越过这一行:

JAXBContext jaxbContext = JAXBContext.newInstance("foo.bar.package");

它抛出异常 - 这是堆栈跟踪 - 伙计们有什么想法吗?

SEVERE: Unhandled exception or error intercepted
java.lang.NoClassDefFoundError: javax/activation/DataSource
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:172)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:25)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:78)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:97)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:44)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:320)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:198)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:132)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:286)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:358)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:323)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)

最佳答案

您缺少一个 JAR 文件,很可能是您的应用程序中的 activation.jar。编译时必须提供此 JAR(除非它是从您正在使用的第 3 方库调用的)。确保此 JAR 在正确的位置可用,以便应用程序使用它。

关于java - 尝试创建 JAXBContext 时出现未处理的异常 (Jaxb 2.0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/706887/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com