Metro on WebSphere 7 – incompatible exception


Developed a SOAP web service via Metro 2.0.1 (webservices-rt.jar), integrate with Spring via jaxws-spring-1.8.jar and deployed on WebSphere Application Server (WAS) version . See web service below :

File :

public class UserWS {

    private UserBo userBo;

    @WebMethod(exclude = true)
    public UserBo getUserBo() {
        return userBo;

    @WebMethod(exclude = true)
    public void setUserBo(UserBo userBo) {
        this.userBo = userBo;

    @WebMethod(operationName = "listUser")
    public List<User> listUser() throws SOAPException {

       return userBo.listUser();


If everything is fine, the service is work as expected, but, when “userBo.listUser()” hit error and throwing a SOAPException back to the web service’s client :

Client get this :

Exception in thread "main" No Content-type in the header!

WAS log file showing this :

Caused by: java.lang.ClassCastException: 
	incompatible with com.sun.xml.bind.api.JAXBRIContext
	at java.lang.J9VMInternals.initializeImpl(Native Method)
	at java.lang.J9VMInternals.initialize(
	... 34 more

P.S This web service is working on Tomcat, but failed on WebSphere only


The is located at WAS_APPSERVER_PROFILE\plugins\, and Metro library, webservices-rt.jar, also contain one of the instance com.sun.xml.bind.v2.runtime.JAXBContextImpl . When exception raised, WAS is using two different instance to perform a same JAXB binding task, and raise an “java.lang.ClassCastException” incompatible exception.

To fix it, just make sure WAS is using same instance always.

  1. In WAS configuration screen, set module class loader to “parent-first“.
  2. In WAS folder, create a “classes” folder under WAS root folder and put webservices-rt.jar inside, for example, WAS_APPSERVER_PROFILE\classes\webservices-rt.jar.

Restart WAS instance, now WAS will load your webservices-rt.jar always. A dirty way, but it work :).

About the Author

author image
Founder of, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.


3 Comment threads
2 Thread replies
Most reacted comment
Hottest comment thread
4 Comment authors
areizero DeveloperrafdMarkotiagoMetro on WebSphere 7 – incompatible exception Recent comment authors
newest oldest most voted
Metro on WebSphere 7 – incompatible exception

[…] Application Server (WAS) version . See web service below : File : package… [full post] mkyong Mkyong Dot Com jax-wsmetroweb serviceswebsphere 0 0 0 […]


i have found a nother way to get the same result without changing anything in the
aparently if ou place a in the /src/main/resources path with the folowing string.

websphere loads and uses only this contextFactory and the exception is never thrown 🙂

areizero Developer
areizero Developer

You can find a complete Guide for Metro, CXF and Axis on IBM Websphere (WAS) in the next link (Offical guides), some libs can generate conflicts with the WAS .jar libs.