相关疑难解决方法(0)

使用Java EE API替换已弃用的JPMS模块

Java 9 弃用了六个包含Java EE API的模块,它们很快被删除:

  • javax.activation包的java.activation
  • java.corbajavax.activity,javax.rmi,javax.rmi.CORBA,和org.omg.*
  • javax.transaction包的java.transaction
  • 包含所有javax.xml.bind.*包的java.xml.bind
  • java.xml.wsjavax.jws,javax.jws.soap,javax.xml.soap,和所有javax.xml.ws.*
  • javax.annotation包的java.xml.ws.annotation

哪些维护的第三方工件提供了这些API?它们提供这些API或它们必须提供的其他功能并不重要 - 重要的是,它们是这些模块/包的直接替代品吗?

为了更容易收集知识,我回答了迄今为止我所知道的并将答案作为社区维基.我希望人们能够扩展它,而不是写出自己的答案.


在您投票结束之前:

  • 是的,已经有一些关于单个模块的问题,这个问题的答案当然会复制这些信息.但AFAIK没有任何一点可以了解所有这些,我认为这些有很大的价值.
  • 提出图书馆建议的问题通常被认为是偏离主题的,因为"他们倾向于吸引自以为是的答案和垃圾邮件",但我不认为这适用于此.明确描述了一组有效的库:它们必须实现特定的标准.除此之外别无其他,所以我没有看到很多意见和垃圾邮件的风险.

java java-ee java-9 java-module

150
推荐指数
6
解决办法
5万
查看次数

javax.xml.bind.JAXBException在模块路径或类路径上找不到JAXB-API的实现

我正在尝试在Java 9上运行我的Spring Boot应用程序,并且我遇到了JAXB问题,该问题在指南中有所描述,但对我来说并不适用.我添加了对JAXB api的依赖,应用程序开始工作.如果您收到以下异常,则由于缺少使用Java版本> = 9的JAXB缺失实现:

javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:177) ~[jaxb-api-2.3.0.jar:2.3.0]
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:364) ~[jaxb-api-2.3.0.jar:2.3.0]
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:508) ~[jaxb-api-2.3.0.jar:2.3.0]
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:465) ~[jaxb-api-2.3.0.jar:2.3.0]
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:366) ~[jaxb-api-2.3.0.jar:2.3.0]
    at com.sun.jersey.server.impl.wadl.WadlApplicationContextImpl.<init>(WadlApplicationContextImpl.java:107) ~[jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.wadl.WadlFactory.init(WadlFactory.java:100) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.RootResourceUriRules.initWadl(RootResourceUriRules.java:169) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:106) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1359) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:180) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:799) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:795) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) [jersey-core-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790) [jersey-server-1.19.1.jar:1.19.1]
    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509) [jersey-servlet-1.19.1.jar:1.19.1]
    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339) [jersey-servlet-1.19.1.jar:1.19.1]
    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) [jersey-servlet-1.19.1.jar:1.19.1]
    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207) [jersey-servlet-1.19.1.jar:1.19.1]
    at …
Run Code Online (Sandbox Code Playgroud)

xml bind exception jaxb java-9

36
推荐指数
4
解决办法
3万
查看次数

Java 11:在模块路径或类路径上找不到JAXB-API的实现

我有一个小项目,当我让它运行时确实会引发异常。

问题在这里(TestObject.java):

final JAXBContext jaxbContext = JAXBContext.newInstance(...);
Run Code Online (Sandbox Code Playgroud)

我真的不明白为什么会抛出异常。我还创建了一个像超级按钮一样工作的测试(TestTest.java)。请原谅我的名字,但这只是一个小的测试应用程序,它可以与Java 11一起使用。

我遵循以下步骤:javax.xml.bind.JAXBException在模块路径或类路径上未找到 并添加了JAXB-API的实现

compile('javax.xml.bind:jaxb-api:2.3.0')
compile('javax.activation:activation:1.1')
compile('org.glassfish.jaxb:jaxb-runtime:2.3.0')
Run Code Online (Sandbox Code Playgroud)

到我的build.gradle,但随后它抱怨

Error:java: module not found: java.activation
Run Code Online (Sandbox Code Playgroud)

不见了。由于这也从Java 11中删除,因此我添加了:

compile 'com.sun.activation:javax.activation:1.2.0'
Run Code Online (Sandbox Code Playgroud)

但随后引发了很多错误:

Error:java: the unnamed module reads package com.sun.xml.bind from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.util from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.marshaller from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads package com.sun.xml.bind.api from both jaxb.runtime and jaxb.core
Error:java: the unnamed module reads …
Run Code Online (Sandbox Code Playgroud)

java java-platform-module-system java-11

4
推荐指数
3
解决办法
4384
查看次数

XJC Maven插件(jaxb2-maven-plugin)Java 11迁移问题

我目前正在从事Java 11迁移项目,其中jaxb2-maven-plugin已用于XJC任务。由于JDK 11版本中没有XJC可执行文件,因此出现以下错误。

    [ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc (xjc-schema1) on project paymaster-service: Execution xjc-schema1 of goal org.codehaus.mojo:jaxb2-maven-plugin:2.2
:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc: com/sun/codemodel/CodeWriter
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.codehaus.mojo:jaxb2-maven-plugin:2.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/voletis/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/2.2/jaxb2-maven-plugin-2.2.jar
[ERROR] urls[1] = file:/C:/Users/voletis/.m2/repository/javax/xml/bind/jaxb-api/2.2.11/jaxb-api-2.2.11.jar
[ERROR] urls[2] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-core/2.2.11/jaxb-core-2.2.11.jar
[ERROR] urls[3] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
[ERROR] urls[4] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
[ERROR] urls[5] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-jxc/2.2.11/jaxb-jxc-2.2.11.jar
[ERROR] urls[6] = file:/C:/Users/voletis/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M3/qdox-2.0-M3.jar
[ERROR] urls[7] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[8] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[9] = file:/C:/Users/voletis/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
[ERROR] …
Run Code Online (Sandbox Code Playgroud)

java jaxb maven-plugin jaxb2-maven-plugin

2
推荐指数
3
解决办法
3688
查看次数