与 Axis & 的奇怪交互操作系统Gi
场景如下:
我有 2 个带有 axis 1.4 的包,并且它们嵌入了传递依赖项(它们各自调用不同的 Web 服务来完成其工作)。
似乎当一个包在另一个包之前加载时,另一个包会“丢失”,但出现以下异常:
java.lang.RuntimeException: java.lang.ClassCastException: org.apache.axis.transport.http.HTTPSender cannot be cast to org.apache.axis.Handler
我稍微研究了一下轴代码,看起来它实际上正在执行一些与 OSGi 不兼容的类加载(Class .forName 类型的东西),但由于 axis 嵌入在两个包中(并且每个包都有自己的类加载器),我不明白为什么它们会成为问题。
这里有更多的例外:
Caused by: java.lang.ClassCastException: org.apache.axis.transport.http.HTTPSender cannot be cast to org.apache.axis.Handler
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:216)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.mycompany.myappname.webserviceclient.MyAppNameWebservicePortBindingStub.getAllSiteInformations(MyAppNameWebservicePortBindingStub.java:1603)
at com.mycompany.myappname.webserviceclient.MyAppNameWebserviceProxy.getAllSiteInformations(MyAppNameWebserviceProxy.java:164)
at com.mycompany.application.myappnamedisplay.view.MetadataTreeCompositeHolder.buildMetadataTree(MetadataTreeCompositeHolder.java:102)
... 51 more
Caused by: java.lang.ClassCastException: org.apache.axis.transport.http.HTTPSender cannot be cast to org.apache.axis.Handler
at org.apache.axis.deployment.wsdd.WSDDTargetedChain.makeNewInstance(WSDDTargetedChain.java:157)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployableItem.java:274)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableItem.java:260)
at org.apache.axis.deployment.wsdd.WSDDDeployment.getTransport(WSDDDeployment.java:410)
at org.apache.axis.configuration.FileProvider.getTransport(FileProvider.java:257)
at org.apache.axis.AxisEngine.getTransport(AxisEngine.java:332)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:163)
... 59 more
我已经在谷歌上搜索了很多,但似乎找不到任何东西 - 我几乎期望在这里得到另一个风滚草徽章,但话又说回来,也许有人知道这里发生了什么?
提前致谢。
Here is the scenario:
I have 2 bundles with axis 1.4 and it's transitive dependencies embedded in them (they each call a different web service to do their work).
It seems that when one loads before the other, the other bundle "loses" with this exception:
java.lang.RuntimeException: java.lang.ClassCastException: org.apache.axis.transport.http.HTTPSender cannot be cast to org.apache.axis.Handler
I've dug through the axis code a bit and it looks like it is in fact doing some classloading that doesn't jive with OSGi (Class.forName type stuff) but since axis is embedded in both bundles (and each bundle has it's own classloader) I don't see why their would be a problem.
Here is more of the exception:
Caused by: java.lang.ClassCastException: org.apache.axis.transport.http.HTTPSender cannot be cast to org.apache.axis.Handler
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:216)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.mycompany.myappname.webserviceclient.MyAppNameWebservicePortBindingStub.getAllSiteInformations(MyAppNameWebservicePortBindingStub.java:1603)
at com.mycompany.myappname.webserviceclient.MyAppNameWebserviceProxy.getAllSiteInformations(MyAppNameWebserviceProxy.java:164)
at com.mycompany.application.myappnamedisplay.view.MetadataTreeCompositeHolder.buildMetadataTree(MetadataTreeCompositeHolder.java:102)
... 51 more
Caused by: java.lang.ClassCastException: org.apache.axis.transport.http.HTTPSender cannot be cast to org.apache.axis.Handler
at org.apache.axis.deployment.wsdd.WSDDTargetedChain.makeNewInstance(WSDDTargetedChain.java:157)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployableItem.java:274)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableItem.java:260)
at org.apache.axis.deployment.wsdd.WSDDDeployment.getTransport(WSDDDeployment.java:410)
at org.apache.axis.configuration.FileProvider.getTransport(FileProvider.java:257)
at org.apache.axis.AxisEngine.getTransport(AxisEngine.java:332)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:163)
... 59 more
I've googled this quite a bit and I can't seem to find anything - I almost expect to get another tumbleweed badge here, but then again maybe someone has an idea what's going on here?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从评论看来,将 jar 嵌入到包中是行不通的。通过这篇文章更改一些 Axis 1.4 源代码,我们能够让 Axis 1.4 作为捆绑包工作:http://issues.ops4j.org/browse/PAXLOGGING-58
我们还从 springsource Axis 中获取了 MANIFEST.MF,并将其放入新编译的 Axis JAR 中。我们这样做,而不是通过 BND 运行它并尝试配置所有可选的依赖项。 http ://nl.interface21.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.axis&version=1.4.0
(注意:我们不使用 Pax 日志记录但改为使用 Sling 记录器,上面的更改对我们来说效果很好,它们修复了 Axis 从公共日志记录兼容框架获取记录器的方式,这似乎破坏了 OSGi 中的 Axis 1.4。)
我们正在使用的环境:Day CQ。 5.3.0,Felix OSGi 容器。
It looks like from the comments that embedding the jar in the bundles isn't going to work. We were able to get Axis 1.4 to work as a bundle by changing some of the Axis 1.4 source code via this post: http://issues.ops4j.org/browse/PAXLOGGING-58
We also took the MANIFEST.MF from the springsource Axis and just drop it into the newly compiled Axis JAR. We did this instead of running it through BND and trying to configure all the optional dependencies. http://nl.interface21.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.axis&version=1.4.0
(Note: We don't use Pax Logging but instead use the Sling logger and the changes above work fine for us. They fix how Axis gets the Logger from the commons-logging compatible framework, which is what seems to break Axis 1.4 in OSGi.)
Environment we're using: Day CQ 5.3.0, Felix OSGi container.