从 JBoss 发出 http 请求时 Mule 出错
Mule gives error when making http request from JBoss
我有一个 Mule 流正在尝试发出出站 HTTP 请求。
<http:request config-ref="APP_OUT" path="#[message.inboundProperties.'http.request.path']" method="#[message.inboundProperties.'http.method']" doc:name="OUT" sendBodyMode="ALWAYS" parseResponse="false" followRedirects="false">
<http:request-builder>
<http:header headerName="HOST" value="#[message.inboundProperties.'host']"/>
</http:request-builder>
</http:request>
这适用于 Mule studio 以及当 运行 Mule 作为独立的 Java 应用程序时。但是,当我将它作为 webapp 带到 JBoss7 时,我立即收到错误消息。我们可以排除几秒钟后出现的超时错误。
16:56:27,393 SEVERE [org.glassfish.grizzly.nio.SelectorRunner] ([myapp].http.requester.APP_OUT(1) SelectorRunner) doSelect exception: java.lang.IllegalAccessError: tried to access method com.ning.http.client.providers.grizzly.HttpTransactionContext.getAsyncHandler()Lcom/ning/http/client/AsyncHandler; from class org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy
at org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy.getWorkManager(FlowWorkManagerIOStrategy.java:119) [mule-module-http-3.7.2.jar:3.7.2]
at org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy.getThreadPoolFor(FlowWorkManagerIOStrategy.java:90) [mule-module-http-3.7.2.jar:3.7.2]
at org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy.executeIoEvent(FlowWorkManagerIOStrategy.java:69) [mule-module-http-3.7.2.jar:3.7.2]
at org.glassfish.grizzly.strategies.AbstractIOStrategy.executeIoEvent(AbstractIOStrategy.java:89) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.iterateKeyEvents(SelectorRunner.java:414) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.iterateKeys(SelectorRunner.java:383) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.doSelect(SelectorRunner.java:347) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:278) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) [grizzly-framework-2.3.21.jar:2.3.21]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]
有人知道这是否是已知问题吗?我可以看到其他人在 MuleSoft 论坛上发布了同样的问题但没有回复
http://forums.mulesoft.com/questions/30322/mule-372-issue-when-using-httprequest-and-running-1.html
看起来 class 路径上存在冲突的 async-http-client
版本,或者更准确地说,class 加载的 com.ning.http.client.providers.grizzly.HttpTransactionContext
版本是不是 Mule 的 HTTP 模块预期的版本(因此已使用不同版本编译)。
Mule 3.7
期望 1.9.21
:您的 Mule 应用程序中是否打包了不同的版本?或者 JBoss 在父 classloader 中加载不同的版本?如果是前者,请检查您的应用程序的 POM 以确保打包正确的版本,如果是后者,请配置 JBoss classloader 以避免向您的 Mule 应用程序提供此 class 的不兼容版本.
编辑:感谢 OP 的评论,问题确实是由于 Mule HTTP 模块嵌入了不同版本的 HttpTransactionContext
。区别之一是制作 getAsyncHandler
public 以便可以从任何地方调用它(参见 original and Mule's fork)。
这在 Mule Standalone 中有效,因为 the way Mule loads classes with its system classloader:lib/mule
中的 JAR 优先于 lib/opt
。 HTTP 模块 JAR 在前者中,而 async-http-client
在后者中。因此 HttpTransactionContext
的预期版本被加载。
这真的很不幸,因为它使得 运行 Mule Standalone 之外的 Mule 应用程序非常困难,如果不是不可能的话。
在你的情况下,检查 JBoss' classloader 允许你做什么:也许它可以让你微调它并让 Mule JAR 优先于其他 JAR。或者,您需要构建一个 async-http-client
的分支,其中将使用 HttpTransactionContext
的 Mule 版本。你也可以在你自己的项目中引入这个 class 的 Mule 版本,它应该优先于 JAR 中的版本。
我有一个 Mule 流正在尝试发出出站 HTTP 请求。
<http:request config-ref="APP_OUT" path="#[message.inboundProperties.'http.request.path']" method="#[message.inboundProperties.'http.method']" doc:name="OUT" sendBodyMode="ALWAYS" parseResponse="false" followRedirects="false">
<http:request-builder>
<http:header headerName="HOST" value="#[message.inboundProperties.'host']"/>
</http:request-builder>
</http:request>
这适用于 Mule studio 以及当 运行 Mule 作为独立的 Java 应用程序时。但是,当我将它作为 webapp 带到 JBoss7 时,我立即收到错误消息。我们可以排除几秒钟后出现的超时错误。
16:56:27,393 SEVERE [org.glassfish.grizzly.nio.SelectorRunner] ([myapp].http.requester.APP_OUT(1) SelectorRunner) doSelect exception: java.lang.IllegalAccessError: tried to access method com.ning.http.client.providers.grizzly.HttpTransactionContext.getAsyncHandler()Lcom/ning/http/client/AsyncHandler; from class org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy
at org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy.getWorkManager(FlowWorkManagerIOStrategy.java:119) [mule-module-http-3.7.2.jar:3.7.2]
at org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy.getThreadPoolFor(FlowWorkManagerIOStrategy.java:90) [mule-module-http-3.7.2.jar:3.7.2]
at org.mule.module.http.internal.request.grizzly.FlowWorkManagerIOStrategy.executeIoEvent(FlowWorkManagerIOStrategy.java:69) [mule-module-http-3.7.2.jar:3.7.2]
at org.glassfish.grizzly.strategies.AbstractIOStrategy.executeIoEvent(AbstractIOStrategy.java:89) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.iterateKeyEvents(SelectorRunner.java:414) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.iterateKeys(SelectorRunner.java:383) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.doSelect(SelectorRunner.java:347) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:278) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) [grizzly-framework-2.3.21.jar:2.3.21]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) [grizzly-framework-2.3.21.jar:2.3.21]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_67]
有人知道这是否是已知问题吗?我可以看到其他人在 MuleSoft 论坛上发布了同样的问题但没有回复
http://forums.mulesoft.com/questions/30322/mule-372-issue-when-using-httprequest-and-running-1.html
看起来 class 路径上存在冲突的 async-http-client
版本,或者更准确地说,class 加载的 com.ning.http.client.providers.grizzly.HttpTransactionContext
版本是不是 Mule 的 HTTP 模块预期的版本(因此已使用不同版本编译)。
Mule 3.7
期望 1.9.21
:您的 Mule 应用程序中是否打包了不同的版本?或者 JBoss 在父 classloader 中加载不同的版本?如果是前者,请检查您的应用程序的 POM 以确保打包正确的版本,如果是后者,请配置 JBoss classloader 以避免向您的 Mule 应用程序提供此 class 的不兼容版本.
编辑:感谢 OP 的评论,问题确实是由于 Mule HTTP 模块嵌入了不同版本的 HttpTransactionContext
。区别之一是制作 getAsyncHandler
public 以便可以从任何地方调用它(参见 original and Mule's fork)。
这在 Mule Standalone 中有效,因为 the way Mule loads classes with its system classloader:lib/mule
中的 JAR 优先于 lib/opt
。 HTTP 模块 JAR 在前者中,而 async-http-client
在后者中。因此 HttpTransactionContext
的预期版本被加载。
这真的很不幸,因为它使得 运行 Mule Standalone 之外的 Mule 应用程序非常困难,如果不是不可能的话。
在你的情况下,检查 JBoss' classloader 允许你做什么:也许它可以让你微调它并让 Mule JAR 优先于其他 JAR。或者,您需要构建一个 async-http-client
的分支,其中将使用 HttpTransactionContext
的 Mule 版本。你也可以在你自己的项目中引入这个 class 的 Mule 版本,它应该优先于 JAR 中的版本。