java - 在 WildFly 8.1 上运行 Jersey2 REST 客户端时出现问题

标签 java jersey-2.0 jersey-client wildfly-8

我正在尝试将在 Jersey 2.13 上编写的 REST 客户端嵌入到 WildFly 8.1 应用程序服务器。我知道WF8有自己的REST客户端实现(RestEasy)。 WF8 似乎不愿意让 Jersey 活下去。它拦截 Jersey 并替换为自己的类。

这是我的异常日志:

java.lang.LinkageError: org/glassfish/jersey/media/multipart/internal/FormDataParamValueFactoryProvider
org.glassfish.jersey.media.multipart.internal.FormDataParameterInjectionFeature.configure(FormDataParameterInjectionFeature.java:77)
org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1673)
org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1310)
org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1232)
org.jboss.resteasy.spi.ResteasyProviderFactory.register(ResteasyProviderFactory.java:2364)
org.jboss.resteasy.spi.ResteasyProviderFactory.register(ResteasyProviderFactory.java:97)
org.jboss.resteasy.util.FeatureContextDelegate.register(FeatureContextDelegate.java:37)
org.jboss.resteasy.util.FeatureContextDelegate.register(FeatureContextDelegate.java:12)
org.glassfish.jersey.media.multipart.MultiPartFeature.configure(MultiPartFeature.java:64)
org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1673)
org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1310)
org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1232)
org.jboss.resteasy.spi.ResteasyProviderFactory.register(ResteasyProviderFactory.java:2364)
org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration.register(ClientConfiguration.java:168)
org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.register(ClientWebTarget.java:351)
org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.register(ClientWebTarget.java:23)
com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.<init>(JerseyRequest.java:104)
com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest(JerseyRequest.java:62)
com.jaspersoft.jasperserver.jaxrs.client.core.JerseyRequest.buildRequest(JerseyRequest.java:55)
com.jaspersoft.jasperserver.jaxrs.client.apiadapters.serverInfo.ServerInfoService.buildServerInfoRequest(ServerInfoService.java:44)
com.jaspersoft.jasperserver.jaxrs.client.apiadapters.serverInfo.ServerInfoService.edition(ServerInfoService.java:51)
il.alex.jboss.example.MainServlet.doGet(MainServlet.java:26)
javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)

有什么办法可以解决这个问题吗?

更新

修改jboss-deployment-struct文件后:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="resteasy" xmlns="urn:jboss:domain:jaxrs:1.0"/>
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

我得到了

2014-10-28 05:20:14,308] Artifact jboss-another-example:war exploded: Artifact is being deployed, please wait...
[0m17:20:14,570 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "jboss_another_example_war_exploded.war" (runtime-name: "jboss_another_example_war_exploded.war")
[0m[31m17:20:15,571 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."jboss_another_example_war_exploded.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jboss_another_example_war_exploded.war".STRUCTURE: JBAS018733: Failed to process phase STRUCTURE of deployment "jboss_another_example_war_exploded.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_40-ea]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_40-ea]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_40-ea]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018748: Error loading jboss-deployment-structure.xml from /Users/alex/IdeaProjects/jboss-another-example/out/artifacts/jboss_another_example_war_exploded.war/WEB-INF/jboss-deployment-structure.xml
    at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:322) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:294) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:158) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    ... 5 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,13]
Message: JBAS018754: Unexpected content of type 'element start', name is '{urn:jboss:domain:jaxrs:1.0}subsystem', text is: 'null'
    at org.jboss.as.server.deployment.module.descriptor.JBossDeploymentStructureParser12.unexpectedContent(JBossDeploymentStructureParser12.java:1194) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.module.descriptor.JBossDeploymentStructureParser12.parseExcludeSubsystem(JBossDeploymentStructureParser12.java:1100) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.module.descriptor.JBossDeploymentStructureParser12.parseModuleStructureSpec(JBossDeploymentStructureParser12.java:366) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.module.descriptor.JBossDeploymentStructureParser12.parseDeployment(JBossDeploymentStructureParser12.java:267) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.module.descriptor.JBossDeploymentStructureParser12.readElement(JBossDeploymentStructureParser12.java:244) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.server.deployment.module.descriptor.JBossDeploymentStructureParser12.readElement(JBossDeploymentStructureParser12.java:69) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
    at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
    at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.parse(DeploymentStructureDescriptorParser.java:316) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]
    ... 8 more

[0m[31m17:20:15,578 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "jboss_another_example_war_exploded.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"jboss_another_example_war_exploded.war\".STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"jboss_another_example_war_exploded.war\".STRUCTURE: JBAS018733: Failed to process phase STRUCTURE of deployment \"jboss_another_example_war_exploded.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018748: Error loading jboss-deployment-structure.xml from /Users/alex/IdeaProjects/jboss-another-example/out/artifacts/jboss_another_example_war_exploded.war/WEB-INF/jboss-deployment-structure.xml
    Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,13]
Message: JBAS018754: Unexpected content of type 'element start', name is '{urn:jboss:domain:jaxrs:1.0}subsystem', text is: 'null'"}}
[0m[31m17:20:15,582 ERROR [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "jboss_another_example_war_exploded.war" was rolled back with the following failure message: 
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"jboss_another_example_war_exploded.war\".STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"jboss_another_example_war_exploded.war\".STRUCTURE: JBAS018733: Failed to process phase STRUCTURE of deployment \"jboss_another_example_war_exploded.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018748: Error loading jboss-deployment-structure.xml from /Users/alex/IdeaProjects/jboss-another-example/out/artifacts/jboss_another_example_war_exploded.war/WEB-INF/jboss-deployment-structure.xml
    Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,13]
Message: JBAS018754: Unexpected content of type 'element start', name is '{urn:jboss:domain:jaxrs:1.0}subsystem', text is: 'null'"}}
[0m[0m17:20:15,586 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment jboss_another_example_war_exploded.war (runtime-name: jboss_another_example_war_exploded.war) in 4ms
[0m[0m17:20:15,589 INFO  [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.unit."jboss_another_example_war_exploded.war".STRUCTURE

[0m[2014-10-28 05:20:15,667] Artifact jboss-another-example:war exploded: Error during artifact deployment. See server log for details.
[2014-10-28 05:20:15,669] Artifact jboss-another-example:war exploded: java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"jboss_another_example_war_exploded.war\".STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"jboss_another_example_war_exploded.war\".STRUCTURE: JBAS018733: Failed to process phase STRUCTURE of deployment \"jboss_another_example_war_exploded.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018748: Error loading jboss-deployment-structure.xml from /Users/alex/IdeaProjects/jboss-another-example/out/artifacts/jboss_another_example_war_exploded.war/WEB-INF/jboss-deployment-structure.xml
    Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,13]
Message: JBAS018754: Unexpected content of type 'element start', name is '{urn:jboss:domain:jaxrs:1.0}subsystem', text is: 'null'"}}

最佳答案

不确定它是否有效,但尝试发表评论

<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> 

来自你的 Wildfly 配置文件。

如果您在独立模式下运行wildfly,请在standalone.xml中编辑它 或者是domain.xml

关于java - 在 WildFly 8.1 上运行 Jersey2 REST 客户端时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26611492/

相关文章:

file-upload - Jersey ApacheConnector 多部分文件上传 - 未找到多部分边界

java - requestLocationUpdates 抛出错误

java - ProgID和文件扩展名关系

java - 如何使用 java 中的 HtmlUnit 从 HTML 中不在 Form 元素中的 textarea 复制数据?

java - 对于没有保证析构函数的语言,涉及非 gced 内存的语言绑定(bind)?

java - Jersey 客户端下载并保存文件

尝试通过 Rest 调用获取文档时出现 java.lang.OutOfMemoryError

java - 使用 Jersey 解析 XML 中的复杂对象

java - 使用 Jersey 添加新资源

json - JAXRS 客户端 - Pojo 的反序列化问题