【问题标题】:JAX-WS Metro implementation in WildflyWildfly 中的 JAX-WS Metro 实现
【发布时间】:2017-07-24 09:48:01
【问题描述】:

我尝试在 Wildfly 10 中使用 JAX-WS Metro 实现更改默认 (CXF) 实现。我必须执行大量步骤(遵循此 link)并适应 Wildfly 10。

  • 已禁用 Web 服务子系统。
  • 添加 Metro 实现 jar 作为模块
  • 提供了 javax.xml.ws.spi.Provider 文件。
  • 从 javax 模块中禁用 org.jboss.modules。

但是在服务器启动时,初始化时出现异常。这是堆栈跟踪。看起来仍然在实例化 jboss __XMLInputFactory 而不是 Metro 一个。

有什么想法吗?我尝试使用以下类添加文件 services/javax.xml.stream.XMLInputFactory 并且没有运气。

com.sun.xml.internal.stream.XMLInputFactoryImpl

堆栈跟踪

com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.ExceptionInInitializerError
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: javax.servlet.ServletException: com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.ExceptionInInitializerError
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:231)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
    ... 6 more
Caused by: javax.servlet.ServletException: com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.ExceptionInInitializerError
    at com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer.onStartup(WSServletContainerInitializer.java:66)
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:184)
    ... 8 more
Caused by: com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.ExceptionInInitializerError
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:137)
    at com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer.onStartup(WSServletContainerInitializer.java:61)
    ... 9 more
Caused by: java.lang.ExceptionInInitializerError
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:144)
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:127)
    ... 10 more
Caused by: java.lang.ClassCastException: __redirected.__XMLInputFactory cannot be cast to javax.xml.stream.XMLInputFactory
    at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
    at com.sun.xml.ws.api.streaming.XMLStreamReaderFactory.getXMLInputFactory(XMLStreamReaderFactory.java:109)
    at com.sun.xml.ws.api.streaming.XMLStreamReaderFactory.<clinit>(XMLStreamReaderFactory.java:78)
    ... 12 more

【问题讨论】:

  • 这可能很难改变。像这样替换集成实现通常并不容易。也就是说,请确保您的部署中没有包含 JAXP 库或模块中的资源。
  • 谢谢。 JBoss 7.2 中部署了相同的耳朵,但该应用程序还没有工作。我知道他们之间有很多不同之处。但显然较新的版本不像旧版本那样灵活。

标签: jax-ws wildfly wildfly-10


【解决方案1】:

我发现这是由于classloader 问题导致XMLInputFactoryImpl 被加载到多个类加载器中。我的问题中提到的步骤在 wildfly 版本中不起作用,因为它的行为与其前身不同。

我已经设法找到自己的方法让Metrowildfly 10 中工作,如下所示。

  • 将 Metro 实现打包在耳中。并且不需要其他模块破解。 (参考 pom.xml)
  • 移除了默认的 webservice 模块(参考 jboss-deployment-structure.xml)
  • 为每个 EJB 添加了 JNDI 查找,以便在 WAR 中引用它们。由于此过程,CDI 注入 @EJB 似乎不起作用,因此 必须使用 JNDI。

jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <!-- This means that the sub deployments of the EAR will have automatic 
        dependencies on each other except for WAR sub deployments. -->
    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

    <deployment>
        <exclude-subsystems>
            <subsystem name="webservices" />
            <subsystem name="jaxrs" />
        </exclude-subsystems>
        <!-- needed for SOAPHandler otherwise not required. -->
        <dependencies>
            <module name="com.sun.xml.messaging.saaj" export="true" services="export" />
        </dependencies>
    </deployment>

</jboss-deployment-structure>

pom.xml

<dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>webservices-rt</artifactId>
            <version>2.1-b16</version>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>webservices-api</artifactId>
            <version>2.1-b16</version>
        </dependency>
        <dependency>
            <groupId>com.sun.tools.ws</groupId>
            <artifactId>webservices-tools</artifactId>
            <version>2.1-b16</version>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>webservices-extra-api</artifactId>
            <version>2.1-b16</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>webservices-extra</artifactId>
            <version>2.1-b16</version>
        </dependency>

JNDI 查找

// get the deployed name from startup log for each EJBs deployed
deployedName = "java:global/example-ear-2.0-SNAPSHOT/logic/ExampleBean!org.example.com.ExampleBean";
T ejb = (T) initialContext.lookup(deployedName);

【讨论】:

    猜你喜欢
    • 2012-09-22
    • 2012-03-26
    • 1970-01-01
    • 2022-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    • 1970-01-01
    相关资源
    最近更新 更多