gpt4 book ai didi

java - 如果服务器上的 Jboss 实例的行为与本地相同实例的行为不同,应该检查什么?

转载 作者:太空宇宙 更新时间:2023-11-04 09:52:25 25 4
gpt4 key购买 nike

我有一个 Java SOAP Web 服务,它遵循非常标准的架构:

enter image description here

SOAP 客户端联系在 Jboss 实例上运行的 WebService(无论是本地运行还是远程运行),WebService 调用(在 RMI 中)远程应用程序,远程应用程序响应一些数据并将它们返回给请求者。

我的问题大致如下:

  • 在 Jboss 本地实例上,响应正确返回到 SOAP 客户端,如下所示:

    <soap:Envelope>
    <soap:Body>
    <myResponse>
    [ELEMENTS OF MY RESPONSE]
    </myResponse>
    </soap:Body>
    </soap:Envelope>
  • 在 Jboss 远程实例上,即使服务器端和 Jboss 实例上都没有引发任何错误,响应也会返回到 SOAP 客户端:

    <soap:Envelope>
    <soap:Body>
    <myResponse>
    EMPTY IN HERE
    </myResponse>
    </soap:Body>
    </soap:Envelope>

由于它适用于本地实例,因此我对如何解决此问题没有太多想法。这是我到目前为止所尝试过的:

  • 我尝试完全重新编译部署在远程实例上的 .war - 这与本地实例中使用的完全相同。
  • 我尝试反编译远程实例中的 .war 并检查为请求和响应定义的 wsdl/xsd 文件:它们是正确的(并且与本地实例中的文件相同)。
  • 我还尝试在应用程序服务器上附加一个远程调试器,以检查远程 Jboss 实例调用时是否正确准备了响应:服务器端的响应是正确的。
  • 我还尝试在远程 Jboss 服务器上运行另一个请求(与所讨论的请求不同),并且正确返回了响应。
  • 我尝试比较本地和远程实例的 standalone-full.xml (配置文件),我能看到的唯一区别是远程版本中用于远程处理的套接字绑定(bind),而本地版本中没有:

    <socket-binding name="remoting" port="1013"/>
  • 最后,我将远程调试器附加到 Jboss 远程实例,并检查 WebService 本身发生的情况。输入和输出已准备就绪:

    @WebMethod
    @WebResult(name = "ProductEvaluation")
    public ProductEvaluations myAPIRequest(@WebParam(name = "XmlProducts") final XmlProducts xmlProducts,
    @WebParam(name = "ConnectedToRealtime") final boolean connectedToRealtime,
    @WebParam(name = "Timeout") final Timeout timeout) throws ProductEvaluationFault, TimeoutFault, ProductConfigurationFault, SecurityFault {
    try {
    // some stuff here...
    return result; //result contains what I want
    } catch (SecurityException e) {
    throw new SecurityFault(e.getMessage());
    }
    }

    堆栈中较早出现的所有内容都是通用的:

    NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62  
    DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
    Method.invoke(Object, Object...) line: 498
    ManagedReferenceMethodInterceptor.processInvocation(InterceptorContext) line: 52
    InterceptorContext.proceed() line: 340
    ConcurrentContextInterceptor.processInvocation(InterceptorContext) line: 45
    InterceptorContext.proceed() line: 340
    InitialInterceptor.processInvocation(InterceptorContext) line: 21
    InterceptorContext.proceed() line: 340
    ChainedInterceptor.processInvocation(InterceptorContext) line: 61
    ComponentDispatcherInterceptor.processInvocation(InterceptorContext) line: 52
    InterceptorContext.proceed() line: 340
    WSComponentInstanceAssociationInterceptor.processInvocation(InterceptorContext) line: 56
    InterceptorContext.proceed() line: 340
    InterceptorContext.run() line: 356
    WildFlySecurityManager.doChecked(PrivilegedExceptionAction<T>) line: 636
    AccessCheckingInterceptor.processInvocation(InterceptorContext) line: 61
    InterceptorContext.proceed() line: 340
    InterceptorContext.run() line: 356
    PrivilegedWithCombinerInterceptor.processInvocation(InterceptorContext) line: 80
    InterceptorContext.proceed() line: 340
    ChainedInterceptor.processInvocation(InterceptorContext) line: 61
    ViewService$View.invoke(InterceptorContext) line: 195
    InvocationHandlerJAXWS(AbstractInvocationHandler).invoke(Endpoint, Invocation) line: 137
    JBossWSInvoker.performInvocation(Exchange, Object, Method, Object[]) line: 169
    JBossWSInvoker(AbstractInvoker).invoke(Exchange, Object, Method, List<Object>) line: 96
    JBossWSInvoker(AbstractJAXWSMethodInvoker).invoke(Exchange, Object, Method, List<Object>) line: 232
    JBossWSInvoker(JAXWSMethodInvoker).invoke(Exchange, Object, Method, List<Object>) line: 85
    JBossWSInvoker.invoke(Exchange, Object) line: 145
    ServiceInvokerInterceptor$1.run() line: 59
    Executors$RunnableAdapter<T>.call() line: 511
    ServiceInvokerInterceptor$2(FutureTask<V>).run() line: 266
    ServiceInvokerInterceptor$2.run() line: 126
    SynchronousExecutor.execute(Runnable) line: 37
    ServiceInvokerInterceptor.handleMessage(Message) line: 131
    PhaseInterceptorChain.doIntercept(Message) line: 308
    ChainInitiationObserver.onMessage(Message) line: 121
    ServletDestination(AbstractHTTPDestination).invoke(ServletConfig, ServletContext, HttpServletRequest, HttpServletResponse) line: 251
    RequestHandlerImpl.handleHttpRequest(Endpoint, HttpServletRequest, HttpServletResponse, ServletContext) line: 108
    ServletHelper.callRequestHandler(HttpServletRequest, HttpServletResponse, ServletContext, Bus, Endpoint) line: 134
    CXFServletExt.invoke(HttpServletRequest, HttpServletResponse) line: 88
    CXFServletExt(AbstractHTTPServlet).handleRequest(HttpServletRequest, HttpServletResponse) line: 293
    CXFServletExt(AbstractHTTPServlet).doPost(HttpServletRequest, HttpServletResponse) line: 212
    CXFServletExt(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 707
    CXFServletExt.service(HttpServletRequest, HttpServletResponse, ServletContext) line: 136
    WSFServlet.service(HttpServletRequest, HttpServletResponse) line: 140
    WSFServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 790
    ServletHandler.handleRequest(HttpServerExchange) line: 85
    ServletSecurityRoleHandler.handleRequest(HttpServerExchange) line: 62
    ServletDispatchingHandler.handleRequest(HttpServerExchange) line: 36
    SecurityContextAssociationHandler.handleRequest(HttpServerExchange) line: 78
    PredicateHandler.handleRequest(HttpServerExchange) line: 43
    SSLInformationAssociationHandler.handleRequest(HttpServerExchange) line: 131
    ServletAuthenticationCallHandler.handleRequest(HttpServerExchange) line: 57
    PredicateHandler.handleRequest(HttpServerExchange) line: 43
    ServletConfidentialityConstraintHandler(AbstractConfidentialityHandler).handleRequest(HttpServerExchange) line: 46
    ServletConfidentialityConstraintHandler.handleRequest(HttpServerExchange) line: 64
    AuthenticationMechanismsHandler.handleRequest(HttpServerExchange) line: 60
    CachedAuthenticatedSessionHandler.handleRequest(HttpServerExchange) line: 77
    NotificationReceiverHandler.handleRequest(HttpServerExchange) line: 50
    SecurityInitialHandler(AbstractSecurityContextAssociationHandler).handleRequest(HttpServerExchange) line: 43
    PredicateHandler.handleRequest(HttpServerExchange) line: 43
    JACCContextIdHandler.handleRequest(HttpServerExchange) line: 61
    PredicateHandler.handleRequest(HttpServerExchange) line: 43
    PredicateHandler.handleRequest(HttpServerExchange) line: 43
    ServletInitialHandler.handleFirstRequest(HttpServerExchange, ServletChain, ServletRequestContext, ServletRequest, ServletResponse) line: 285
    ServletInitialHandler.dispatchRequest(HttpServerExchange, ServletRequestContext, ServletChain, DispatcherType) line: 264
    ServletInitialHandler.access$000(ServletInitialHandler, HttpServerExchange, ServletRequestContext, ServletChain, DispatcherType) line: 81
    ServletInitialHandler$1.handleRequest(HttpServerExchange) line: 175
    Connectors.executeRootHandler(HttpHandler, HttpServerExchange) line: 202
    HttpServerExchange$1.run() line: 792
    XnioWorker$TaskPool(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: 1142
    ThreadPoolExecutor$Worker.run() line: 617
    Thread.run() line: 748

有人知道如何调试此类问题吗?我忘记检查任何配置文件吗?

最佳答案

经过几个小时的努力,我终于弄清楚自己出了什么问题。

虽然这看起来可能是一个简单的拼写错误,但它让我损失了很多时间,并且显示了 Jboss 的远程实例和本地实例之间有趣的行为差异,因此我发布了一个答案,以便为犯同样错误的人腾出一些时间。

我开发的新@WebMethod是这样的:

@WebMethod
@WebResult(name = "ProductEvaluation")
public ProductEvaluations myAPIRequest(@WebParam(name = "XmlProducts") final XmlProducts xmlProducts,
@WebParam(name = "ConnectedToRealtime") final boolean connectedToRealtime,
@WebParam(name = "Timeout") final Timeout timeout) throws ProductEvaluationFault, TimeoutFault, ProductConfigurationFault, SecurityFault {
try {
// some stuff here...
return result; //result contains what I want
} catch (SecurityException e) {
throw new SecurityFault(e.getMessage());
}
}

正如你可能注意到的(我实际上花了 4 个小时才注意到它,所以也许它不是那么明显):

  • 函数的返回类型为 ProductEvaluations(即 ProductEvaluation 列表),这也是在 wsdlxsd 中指定的内容
  • 但是,我忘记了 @WebResult(name="ProductEvaluation") 上方注释上的 s

根据我的经验,因此,我注意到:

  • 当Jboss本地运行时,注释@WebResult会被忽略,无论如何都会返回结果。
  • 但是,当 Jboss 远程运行时,此映射就完成了。因此,由于我返回 ProductEvaluations (带有 s),但说 @WebResultProductEvaluation (没有 s),那么远程服务器不会映射任何内容,并且响应为空。

关于java - 如果服务器上的 Jboss 实例的行为与本地相同实例的行为不同,应该检查什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54551417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com