4

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.

javamonkey79
  • 17,443
  • 36
  • 114
  • 172
  • 2
    Axis 1 and OSGi... now there's a match made in hell. Why not use a web-service stack written in this century? – skaffman Dec 30 '10 at 21:59
  • I couldn't agree more - I really despise Axis but... I've tried using other web service clients but have had no success. I have an open question [here](http://stackoverflow.com/questions/4406752/how-to-generate-web-service-client-with-apache-cxf-in-eclipse-helios) if you can help alleviate me of the pain known as axis. – javamonkey79 Dec 30 '10 at 22:20
  • Or I'd be happy to open a new question on how to generate java web service clients **WITHOUT** axis if you prefer. – javamonkey79 Dec 30 '10 at 22:23
  • So just use CXF (or Java6 JAX-WS) without all the Eclipse rubbish. It's simple enough to configure manually. – skaffman Dec 30 '10 at 22:30
  • Is there a tutorial or something out there? I'd be happy to ditch this devil :) you can post it [here](http://stackoverflow.com/questions/4566774/easy-way-to-generate-web-service-clients-in-java-without-using-axis) if you feel so inclined. – javamonkey79 Dec 30 '10 at 22:33
  • 3
    Embedding Axis in both bundles is likely to be the source of the problem. It looks like the `org.apache.axis.Handler` class is being loaded by the classloaders of both bundles, but you're communicating a subclass instance between them. Classes are not equal (even if they're the "same" class) if loaded by different classloaders. Sorry this isn't a clear and definitive answer (hence only posted as a comment). But it may help you start to sniff out the answer. – Neil Bartlett Dec 31 '10 at 01:57
  • @Neil - I kinda thought that might be the case. That even though they were of the same class they were not equal because they were in different classloaders. I tried putting Axis in it's own bundle and using it but it was pretty painful as well. – javamonkey79 Dec 31 '10 at 02:47
  • The embedded Axis libraries, are they different versions? As in, the two bundles have different versions of Axis embedded in them. We use Axis as well, but it's Axis2 and it has it's own bundle. – omerkudat Dec 31 '10 at 13:37

1 Answers1

4

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.

Joseph Erickson
  • 2,304
  • 20
  • 29
  • That's interesting. If I had any desire to get it to work with Axis anymore I'd go back and try this. But at this point I've already moved on to CXF. You can actually get CXF as a standalone bundle with no dependencies built and ready to go right from their website. It's pretty big (size wise), but I've found it to be worth it. Thanks for posting, +1. – javamonkey79 Jan 20 '11 at 17:03
  • Do you have the source code for the Axis OSGI bundle available? I have exactly the same problem as the author and I'm trying to find a project I could import into Eclipse workspace to build this Axis1 Bundle together with my other bundles so I can set up the dependency. – Alex Nov 15 '11 at 07:33
  • ok, I see a p2 repository with the bundles here: http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository but still need to figure out the chain of required bundles. ahh.... – Alex Nov 15 '11 at 08:04
  • New link to Pax-Logging patch: https://ops4j1.jira.com/browse/PAXLOGGING-58 and Spring repo: http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.axis&version=1.4.0 – havana59er Nov 11 '14 at 00:25