当前位置: 首页 > 知识库问答 >
问题:

Quarkus中的SOAP Webservice因未知的JAXBContext实现而失败

常经赋
2023-03-14

我有一个Quarkus服务,我在启动时发布了一个SOAP服务,如下所示:

@WebService(serviceName = "/service", portName = "ServicePort")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@ApplicationScoped
public class Astute implements AstuteManager {

  void onStart(@Observes StartupEvent ev) {
    String url = "http://localhost:9005/";
    Endpoint.publish(url, this);        
}

@WebMethod(operationName = "Retrieve", action = "Retrieve")
@WebResult(name = "response", targetNamespace = "http://some.namepsace")
@RequestWrapper(localName = "RetrieveInfo", targetNamespace = "http://some.namepsace", 
     className = "dto.RetrieveDto")
@ResponseWrapper(localName = "RetrieveReply", targetNamespace = "http://some.namespace", 
    className = "dto.RetrieveReplyDto")
public RetrieveReplyDto retrieveClientPortfolio(
    @WebParam(name = "request", targetNamespace = "http://some.namespace") RetrieveInfo request) {
    //do something
}

当我到达该endpoint时,我得到:

SEVERE [com.sun.xml.int.ws.tra.htt.HttpAdapter] (pool-4-thread-1) Unknown JAXBContext implementation: 
   class com.sun.xml.bind.v2.runtime.JAXBContextImpl: com.sun.xml.internal.ws.spi.db.DatabindingException: 
   Unknown JAXBContext implementation: class com.sun.xml.bind.v2.runtime.JAXBContextImpl
        at com.sun.xml.internal.ws.spi.db.BindingContextFactory.getJAXBFactory(BindingContextFactory.java:192)
        at com.sun.xml.internal.ws.spi.db.BindingContextFactory.create(BindingContextFactory.java:134)
        at com.sun.xml.internal.ws.message.jaxb.JAXBMessage.create(JAXBMessage.java:152)
        at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createSOAP11Fault(SOAPFaultBuilder.java:424)
        at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:201)
        at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:189)
        at com.sun.xml.internal.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:411)
        at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:706)
        at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:260)
        at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:98)
        at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:82)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
        at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
        at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
        at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

我想这可能是一个依赖冲突,但是我的依赖树中没有什么特别的。这是从Quarkus启动SOAP服务的正确方法吗?

以下是pom中的依赖项:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jaxb</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jdbc-mssql</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
     <version>3.7</version>
</dependency>

quar kus 1 . 2 . 0版

共有1个答案

凤伟泽
2023-03-14

我认为这可能是一个类加载问题,类似于我们过去在JAXB中看到的情况,当时一些类来自JDK本身,一些来自依赖项。

您能否尝试:-升级到1.3.0.Alpha1(使用< code>quarkus-bom而不是< code > quar kus-universe-BOM )并升级Quarkus Maven插件版本-然后将以下依赖项添加到您的< code>pom.xml中:

<dependency>
  <groupId>javax.xml.ws</groupId>
  <artifactId>jaxws-api</artifactId>
  <version>2.3.1</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>rt</artifactId>
  <version>2.3.1</version>
</dependency>

看看它是否解决了你的问题。

如果没有,请创建一个简单的复制程序,并在我们的GitHub上创建一个问题,以便我们可以更仔细地查看。

 类似资料: