Axis 2 Web service error

An error in web-services –

 

exception in stub ==java.lang.LinkageError: loader constraint violation: when resolving method "com.TestClass.getOMElement(Ljavax/xml/namespace/QName;Lorg/apache/axiom/om/OMFactory;)Lorg/apache/axiom/om/OMElement;" the class loader (instance of org/apache/axis2/deployment/DeploymentClassLoader) of the current class, com/TestServiceClass, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, com/ibm/ecris/service/components/TestClass, have different Class objects for the type org/apache/axiom/om/OMFactory used in the signature

 

It comes up when another class with same name is already loaded in ClassLoader (generally during start of web-server, perhaps in different project) and we don’t know about it. The already loaded class is different than the class being loaded at this time. In this case, class being initialized/loaded/used is TestClass which is already loaded with different signatures and therefore this error pops up. So make sure that you load only one instance of right class at right time.