相关疑难解决方法(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万
查看次数

Java 11包javax.xml.bind不存在

我正在尝试使用JAXB将XML数据反序列化为Java内容树,在解组时验证XML数据:

try {
  JAXBContext context = JAXBContext.newInstance("com.acme.foo");
  Unmarshaller unmarshaller = context.createUnmarshaller();
  unmarshaller.setSchema(schema);
  FooObject fooObj = (FooObject) unmarshaller.unmarshal(new File("foo.xml"));
} catch (UnmarshalException ex) {
  ex.printStackTrace();
} catch (JAXBException ex) {
  ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

当我使用Java 8构建项目时,它很好,但使用Java 11构建它失败并出现编译错误:

package javax.xml.bind does not exist
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

java jaxb java-11

99
推荐指数
1
解决办法
9万
查看次数

没有端点适配器; 您的端点是使用@Endpoint注释的,还是实现了MessageHandler或PayloadEndpoint等受支持的接口?

我正在努力使用带有JMS示例的Spring-WS.我按照Spring的建议设置了Spring-WS和JMS接线.但我一直得到以下错误.我不知道如何绕过这个问题,任何帮助将不胜感激:

[org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver] - 
Resolving exception from endpoint 
[org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]: 
java.lang.IllegalStateException: No adapter for endpoint 
[org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]: 
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?

[org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver] - Resolving exception from endpoint
[org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]: 
java.lang.IllegalStateException: No adapter for endpoint [org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]: 
Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?

[org.springframework.ws.soap.server.SoapMessageDispatcher] - 
Endpoint invocation resulted in exception - responding with Fault
java.lang.IllegalStateException: No adapter for endpoint  [org.springframework.ws.samples.mtom.ws.ImageRepositoryEndpoint@1c8b0b1]: 
Is your …
Run Code Online (Sandbox Code Playgroud)

java spring-ws jms

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

使用 ForkJoinPool Java 找不到 JAXB 类

我使用 jaxb 进行解组,但是当我使用 ForkJoinPoolexecute() 方法时,我得到一个“java.log.ClassNotFoundException:com.sun.xml.internal.bind.v2.ContextFactory”,但我确信存在在我的运行时的类路径中,因为当我不使用 ForkJoinPool 时它可以正常工作......你知道这个问题或解决方法吗?

我使用Java 11

我的代码:

ForkJoinPool commonPool = ForkJoinPool.commonPool();
        commonPool.execute(() -> {
            try {
                String messageFileContent = Files.readString(Paths.get(
                        this.getClass().getClassLoader().getResource("xml-to-process.xml").getPath()));

                JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
                // avoiding schema validation for more performance
                jaxbUnmarshaller.setSchema(null);
                UpdateWorkOrder updateWorkOrder = (UpdateWorkOrder) jaxbUnmarshaller.unmarshal(new StringReader(messageFileContent));
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
Run Code Online (Sandbox Code Playgroud)

这很奇怪不是...?在ForkJoinPool的execute()之外,解析是正确执行的。

错误是:

javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at …
Run Code Online (Sandbox Code Playgroud)

java jaxb forkjoinpool

7
推荐指数
2
解决办法
4030
查看次数

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
查看次数

JDK11 + spring boot = JAXBException:在模块路径或类路径上没有找到JAXB-API的实现

我有一个基于官方指南的简单 spring 项目来使用 Web 服务。此示例似乎针对 JDK 8,但我想使用最新的 LTS,JDK 11。

我已经修改了该pom.xml文件并添加了一些似乎已从 JDK 中删除的依赖项,即:

        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.3.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.3.2</version>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>rt</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>com.sun.activation</groupId>
            <artifactId>javax.activation</artifactId>
            <version>1.2.0</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

但是,我似乎无法启动应用程序,总是收到此错误:

?  spring-test git:(master) mvn spring-boot:run
[INFO] Scanning for projects...
...
org.springframework.ws.soap.client.SoapFaultClientException: Implementation of JAXB-API has not been found on module path or classpath.
    at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault (SoapFaultMessageResolver.java:38)
    at org.springframework.ws.client.core.WebServiceTemplate.handleFault (WebServiceTemplate.java:830)
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive (WebServiceTemplate.java:624)
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive (WebServiceTemplate.java:555)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive (WebServiceTemplate.java:390)
    at com.example.demo.CountryClient.getCountry (CountryClient.java:21)
    at com.example.demo.DemoApplication.lambda$lookup$0 …
Run Code Online (Sandbox Code Playgroud)

spring-boot

4
推荐指数
1
解决办法
6636
查看次数

Intellij Jpa 控制台数据库架构

当我想在 Intellij JPA 控制台中进行查询时,我收到relation "topic" does not exist. jpql 查询select t from Topic t。我正在使用 spring boot,我将 jpa 添加到模块中,持久性工具栏运行良好,但 jpa 控制台没有。我认为 JPA 控制台在正确的数据库架构中找不到,但数据源选择了正确。

JPA 控制台打印:[2019-07-19 12:49:59] [42P01] 错误:关系“主题”不存在 [2019-07-19 12:49:59] 位置:60

postgresql intellij-idea spring-data-jpa spring-boot

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