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!!!