如果服务器上的 Jboss 实例的行为与本地相同实例的行为不同,要检查什么?
What to check if Jboss instance on server behaves differently than the same instance locally?
我有一个 Java 遵循相当标准架构的 SOAP Web 服务:
SOAP 客户端联系 Jboss 实例上的 WebService 运行ning(无论是 运行ning 本地还是远程),WebService 调用(在 RMI 中)远程应用程序,它以一些数据和 returns 响应请求者。
我的问题大致如下:
在 Jboss 本地实例上,响应正确返回到 SOAP 客户端,如下所示:
<soap:Envelope>
<soap:Body>
<myResponse>
[ELEMENTS OF MY RESPONSE]
</myResponse>
</soap:Body>
</soap:Envelope>
在 Jboss 远程实例上,响应返回 empty 给 SOAP 客户端,即使在服务器端也没有引发任何错误也不在 Jboss 实例上:
<soap:Envelope>
<soap:Body>
<myResponse>
EMPTY IN HERE
</myResponse>
</soap:Body>
</soap:Envelope>
由于它适用于本地实例,因此我对如何解决此问题没有太多想法。这是我到目前为止尝试过的:
- 我已经尝试完全重新编译部署在远程实例上的
.war
- 这与本地实例中使用的完全相同。
- 我尝试反编译远程实例中的
.war
并检查为请求和响应定义的 wsdl
/ xsd
文件:它们是正确的(并且等于本地实例中的那些,重要的是)。
- 我还尝试在应用程序服务器上附加一个远程调试器,以检查在远程 Jboss 实例调用时是否正确准备了响应:服务器端的响应是正确的。
- 我也曾尝试 运行 远程 Jboss 服务器上的另一个请求(与所讨论的请求不同),并且正确返回了响应。
我试图比较本地和远程实例的 standalone-full.xml
(配置文件),我能看到的唯一区别是远程版本中用于远程处理的套接字绑定我在本地版本中没有:
<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.run() line: 59
Executors$RunnableAdapter<T>.call() line: 511
ServiceInvokerInterceptor(FutureTask<V>).run() line: 266
ServiceInvokerInterceptor.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[=15=]0(ServletInitialHandler, HttpServerExchange, ServletRequestContext, ServletChain, DispatcherType) line: 81
ServletInitialHandler.handleRequest(HttpServerExchange) line: 175
Connectors.executeRootHandler(HttpHandler, HttpServerExchange) line: 202
HttpServerExchange.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 个小时才注意到它,所以它可能不是那么明显):
- 函数的 return 类型是
ProductEvaluations
(表示 ProductEvaluation
的列表),这也是 wsdl
和 xsd
- 但是,我忘记了
@WebResult(name="ProductEvaluation")
上面注释中的 s
根据我的经验,因此,我注意到:
- 当Jboss 在本地运行时,注解
@WebResult
将被忽略,结果无论如何都是return。
- 然而,当Jboss远程运行时,这个映射就完成了。因此,由于我 returning
ProductEvaluations
(带有 s
)但说 @WebResult
是 ProductEvaluation
(没有 s
),然后远程服务器没有映射任何东西,响应是空的。
我有一个 Java 遵循相当标准架构的 SOAP Web 服务:
SOAP 客户端联系 Jboss 实例上的 WebService 运行ning(无论是 运行ning 本地还是远程),WebService 调用(在 RMI 中)远程应用程序,它以一些数据和 returns 响应请求者。
我的问题大致如下:
在 Jboss 本地实例上,响应正确返回到 SOAP 客户端,如下所示:
<soap:Envelope> <soap:Body> <myResponse> [ELEMENTS OF MY RESPONSE] </myResponse> </soap:Body> </soap:Envelope>
在 Jboss 远程实例上,响应返回 empty 给 SOAP 客户端,即使在服务器端也没有引发任何错误也不在 Jboss 实例上:
<soap:Envelope> <soap:Body> <myResponse> EMPTY IN HERE </myResponse> </soap:Body> </soap:Envelope>
由于它适用于本地实例,因此我对如何解决此问题没有太多想法。这是我到目前为止尝试过的:
- 我已经尝试完全重新编译部署在远程实例上的
.war
- 这与本地实例中使用的完全相同。 - 我尝试反编译远程实例中的
.war
并检查为请求和响应定义的wsdl
/xsd
文件:它们是正确的(并且等于本地实例中的那些,重要的是)。 - 我还尝试在应用程序服务器上附加一个远程调试器,以检查在远程 Jboss 实例调用时是否正确准备了响应:服务器端的响应是正确的。
- 我也曾尝试 运行 远程 Jboss 服务器上的另一个请求(与所讨论的请求不同),并且正确返回了响应。
我试图比较本地和远程实例的
standalone-full.xml
(配置文件),我能看到的唯一区别是远程版本中用于远程处理的套接字绑定我在本地版本中没有:<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.run() line: 59 Executors$RunnableAdapter<T>.call() line: 511 ServiceInvokerInterceptor(FutureTask<V>).run() line: 266 ServiceInvokerInterceptor.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[=15=]0(ServletInitialHandler, HttpServerExchange, ServletRequestContext, ServletChain, DispatcherType) line: 81 ServletInitialHandler.handleRequest(HttpServerExchange) line: 175 Connectors.executeRootHandler(HttpHandler, HttpServerExchange) line: 202 HttpServerExchange.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 个小时才注意到它,所以它可能不是那么明显):
- 函数的 return 类型是
ProductEvaluations
(表示ProductEvaluation
的列表),这也是wsdl
和xsd
- 但是,我忘记了
@WebResult(name="ProductEvaluation")
上面注释中的
s
根据我的经验,因此,我注意到:
- 当Jboss 在本地运行时,注解
@WebResult
将被忽略,结果无论如何都是return。 - 然而,当Jboss远程运行时,这个映射就完成了。因此,由于我 returning
ProductEvaluations
(带有s
)但说@WebResult
是ProductEvaluation
(没有s
),然后远程服务器没有映射任何东西,响应是空的。