CXF on IBM WebSphere 7 – Deployment Pitfalls

Standard
Spread the love

Just recently I deployed CXF enabled application on websphere 7 and came across many issues. The issues were not with respect to configuration problems but were mostly related to the classes used internally by CXF (version 2.1, I guess) framework. Surpizingly these issues dont pop-up on JBoss server (Its like saying, hey look my code works on my machine, I dont know what went wrong with yours, it simply doesn’t kick. Heard that a lot in college days 😉

Anyways, here are couple of issues that almost eat my brain (though first one was simple, second was disaster.)
NPE (Null Pointer Exception) with method callSWARefMethod of org.apache.cxf.jaxws.interceptors.SwAOutInterceptor
This exception occurs at runtime, while invoking webservice using CXF client. One can simply figure out the problem by having look at what SwAoutInterceptor does. A closer look at the declaration of SWA_REF_METHOD map reveals all the answers (behavior of ConcurrentHashMap in JDK 1.6). The simple way to get rid of this exception is to upgrade CXF version. (I used CXF 2.2.10)

Exception in thread “main” java.lang.ClassCastException: hello.mypackage.MyClass$JaxbAccessorF_someFieldID cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor
One more weirdo exception and I was left almost clueless as many reported this exception, but there was no proper answer as what to do to get rid of this exception.
Check following exception stack trace

Exception in thread "main" java.lang.ClassCastException: hello.mypackage.MyClass$JaxbAccessorF_someFieldID cannot be cast to com.sun.xml.bind.v2.runtime.reflect.Accessor 
    at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.instanciate(OptimizedAccessorFactory.java:199) 
    at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:191)

I tried many options like using “CodeSource” to identify the JAR which loaded the class, using ClassViewer facility, changing classloader hierarchy etc. but hushhhh nothing working. Finally I replaced, JAXB libraries in my application with older version (I previously had JAXB libraries which come bundled with CXF 2.2.10 and so I reverted back JAXB version to 2.1.7).
And Voila… with these two fixes my application got deployed on websphere and it worked.

Hope it helps!!!

3 thoughts on “CXF on IBM WebSphere 7 – Deployment Pitfalls

  1. kumarasamy

    Hi,

    Im having different issue and I couldnt contact you via contact link.

    Here is my issue,

    I’m developing webservice using CXF 2.5.1, Spring 3.1.0 and Websphere 6.1. Its working fine with proper client program. but if I try to generate the WSDL from IE, getting error(says something configuration error) related to wsdl4j-1.6.2.jar.

    In order to generate Webservice WSDL from IE, WebSphere server classpath order has to be modified(Application first) but this is just the work around. Need to find out the proper solution.

    did you face this problem in you experience ?

    Thanks
    Kumar

  2. Narayana Koppisetty

    Hello Sir, Now a days, i hope your busy with managing ICD team, that’s why not seeing any updates on Carbonrider right?

Leave a Reply

Your email address will not be published. Required fields are marked *