0

I have exposed a web service however when client trying to consume the service I can see there is a ClassCastException exception in the server log. and request is not reaching the web service. When I am trying to call the web service it is working from SOAP UI.

java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext.

I have tried using these two solution

java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext

ClassCastException: Cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor

However in my weblogic folder I could not find the conflicting jar.

J-Alex
  • 6,881
  • 10
  • 46
  • 64
Sandesh Dhotre
  • 33
  • 1
  • 11
  • Please add the code and specify what exactly you tried. – J-Alex May 17 '18 at 13:35
  • I have tried sending the request using SOAP-UI and it is working properly. I see logs from web service code. however when the client who is supposed to consume web service sending the request to web service there is a Exception in Weblogic and request is not reaching to web service I do not see any logging from web services code. I searched by using ClassCastException and found that it happens when there is a conflict with the jar so I tried to find the class JAXBRIContext in Weblogic if there are multiple jar with same class however there are no conflicting jar – Sandesh Dhotre May 17 '18 at 14:06

1 Answers1

0

After investigation I found the issue It was due to wrong wsdl used by the client to call the webservice. Client was using the old wsdl and webservice hosted had a different wsdl.

To trace the issue I enabled http logging on server to check the request send by the client. After comparing the SOAP-UI request with client request I found one namespace was different in the request. After identifying the issue I asked the client to generate the stubs classes using new wsdl and call the webservice and it worked.

The confusion was due to below exception. All the solution were asking to check conflicting jar.

java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext.
Sandesh Dhotre
  • 33
  • 1
  • 11