【问题标题】:Implementation of Jakarta XML Binding-API not found?没有找到 Jakarta XML Binding-API 的实现?
【发布时间】:2021-07-27 06:17:02
【问题描述】:

我的背景:

  • BND(带有 Eclipse IDE 的 bndtools);

  • OSGI (-runfw: org.eclipse.osgi;version='[3.16.100.v20201030-1916,3.16.200.v20210226-1447]') ;

  • 符文:JavaSE-1.8

  • 在 bnd.launch 文件中:

-runbundles: \
  org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\
  org.apache.felix.gogo.runtime;version='[1.1.4,1.1.5)',\
  org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\
  org.apache.commons.commons-fileupload;version='[1.4.0,1.4.1)',\
  org.apache.commons.commons-io;version='[2.8.0,2.8.1)',\
  org.apache.felix.webconsole;version='[4.6.0,4.6.1)',\
  org.apache.felix.http.jetty;version='[4.1.6,4.1.7)',\
  org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
  org.apache.felix.scr;version='[2.1.24,2.1.25)',\
  org.eclipse.equinox.cm;version='[1.5.0,1.5.1)',\
  org.eclipse.equinox.console;version='[1.4.300,1.4.301)',\
  org.eclipse.equinox.device;version='[1.1.100,1.1.101)',\
  org.eclipse.osgi.services;version='[3.10.0,3.10.1)',\
  org.eclipse.osgi.util;version='[3.6.0,3.6.1)',\
  ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
  ch.qos.logback.core;version='[1.2.3,1.2.4)',\
  org.apache.felix.logback;version='[1.0.2,1.0.3)',\
  slf4j.api;version='[1.7.30,1.7.31)',\
  com.sun.activation.jakarta.activation;version='[2.0.1,2.0.2)',\
  jakarta.xml.bind-api;version='[3.0.1,3.0.2)',\
  com.sun.xml.bind.jaxb-osgi;version='[3.0.1,3.0.2)'
  • 根本不使用任何 POM.xml 文件

当我启动应用程序时,我得到一个

jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
 - with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
  at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:255)
  at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:243)
  at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:407)
  at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:691)
  at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:632)

如果我添加org.glassfish.jaxb.runtime;version='[3.0.1,3.0.2)' 到 runbundles 列表,它不会改变任何东西(同样的例外)。 然后,如果我将 -runpath: org.glassfish.jaxb.runtime;version='[3.0.1,3.0.2)' 添加到 bnd.launch 文件:它也不会改变任何东西(同样的例外)。

我做错了什么?? 谢谢

【问题讨论】:

  • 我应该更仔细地阅读 jaxb 站点。我运行 java 8 所以 jaxb 在 rt.jar ;我只需要在我的代码中导入 javax.xml.xxxx(没有 jakarta.xml.xxx),并在我的 bnd.launch 中撤消对任何 jakarta.xml.xxx 的所有引用 :( 它有效。抱歉有噪音。跨度>

标签: jaxb osgi bnd


【解决方案1】:

您是否在 Java 1.9 或更高版本上运行? (错误消息涉及模块路径。)问题可能是在以后的版本中不再从 JVM 导出 JAXB。这有时会导致 glassfish 的类加载失败而不告诉其根本原因。

您可以添加-runvm -v:class 以获取有关类加载的更多信息。

【讨论】:

  • 感谢您的建议 :) 我应该更仔细地阅读 jaxb 网站。我运行 java 8 所以 jaxb 在 rt.jar ;我只需要在我的代码中导入 javax.xml.xxxx(没有 jakarta.xml.xxx),并在我的 bnd.launch 中撤消对任何 jakarta.xml.xxx 的所有引用 :( 它有效。抱歉有噪音。跨度>
  • 顺便说一句,我有一个Unrecognized option: -v:class Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
  • 它的 -verbose:class
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-17
  • 2019-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-28
  • 1970-01-01
相关资源
最近更新 更多