5

Can someone please help me with a strange problem?

I have a service:

@WebMethod
@WebResult(name = "sendCustomerCommunicationResponse", targetNamespace = "......something/Underwriting/Correspondance/V1", partName = "Body")
public SendCustomerCommunicationResponse sendCustomerCommunication(
    @WebParam(name = "sendCustomerCommunicationRequest", targetNamespace = "........something/Underwriting/Correspondance/V1", partName = "Body")
    SendCustomerCommunicationRequest body)
    throws ServiceException_Exception, SystemException_Exception
;

And locally I'm calling it with :

SendCustomerCommunicationResponse response = correspondanceServicePort.sendCustomerCommunication(sendCustomerCommunicationRequest);

And this works well. But when I'm deploying the application on another server, I'm receiving:

"java.lang.ClassCastException: 
    it.usi.xframe.ub1.batch.services.esb.SendCustomerCommunicationRequest incompatible with 
    it.usi.xframe.ub1.batch.services.esb.SendCustomerCommunicationResponse"

P.S. The application is running on WebSphere server

The request is :

<soapenv:Envelope ...someSchema...>
   <soapenv:Header>
      <v1:TechnicalHeader>
         <v1:correlationId>12742</v1:correlationId>
         <v1:sender>userName</v1:sender>
         <v1:countryCode/>
         <v1:channelId/>
         <v1:userID>userName</v1:userID>
         <v1:operationId>CHANGE_STATUS</v1:operationId>
      </v1:TechnicalHeader>
      <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                                    <wsse:UsernameToken>
                                                <wsse:Username>someUser</wsse:Username>
                                                <wsse:Password>somePassoword</wsse:Password>
                                    </wsse:UsernameToken>
                        </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <v11:sendCustomerCommunicationRequest>
         <v11:eventCode>{"header":{"publishingDate":1474016634749,"eventId":"DEL-NEG","applicationCode":"UB3","correlationId":"9999","language":"IT","channelId":"MOB"},"body":{"ndg":"5106215","additionalInfo":{}}}</v11:eventCode>
      </v11:sendCustomerCommunicationRequest>
   </soapenv:Body>
</soapenv:Envelope>
Aditzu
  • 696
  • 1
  • 14
  • 25
  • No one? Nothing?:( – Aditzu Dec 16 '16 at 08:26
  • Something's trying to assign a request object to a response variable, or vice versa. The call stack of the exception should show where to look. – Bruce T. Dec 16 '16 at 12:10
  • EXECUTE ERROR java.lang.ClassCastException: it.usi.xframe.ub1.batch.services.esb.customerCommunication2.SendCustomerC ommunicationRequest incompatible with it.usi.xframe.ub1.batch.services.esb.customerCommunication2.SendCustomerCommunicationResponseQ ZQat com.sun.proxy.$Proxy84.sendCustomerCommunication(Unknown Source)QZQat it.usi.xframe.ub1.batch.steps.close.ST002CLO.callEsbForPo sitions(ST002CLO.java:241)QZQat it.usi.xframe.ub1.batch.steps.close.ST002CLO.managePositionList(ST002CLO.java:367)QZQat it.usi.xfram e.ub1.batch.steps.close.ST002CLO.run(ST002CLO.java:1 – Aditzu Dec 16 '16 at 12:32
  • 1
    it seems something regarding the proxy but I cannot understand what wrong. Is possible that the proxy expects SendCustomerCommunicationResponse instead of SendCustomerCommunicationRequest as input but I cannot understand why – Aditzu Dec 16 '16 at 12:33
  • I tried also to regenerate the client using wsimport -target 2.0 but the result is the same – Aditzu Dec 16 '16 at 15:25
  • You might try starting clean, with no classes from your prior client project, and see if that resolves it. Something is confusing the proxy. – Bruce T. Dec 18 '16 at 16:08
  • Seems a classloader issue . Check the WAS in the different scopes for duplicated jar files, remote temporal directories. If nothing of this works perform a clean install. – pedrofb Dec 19 '16 at 08:39
  • Post also the SOAP message interchanged (request and response). May be they could be helpful – pedrofb Dec 19 '16 at 08:46
  • might it have to do with an expected standard naming convention you are violating? Are all tomcat and jre versions the same in both your environments? – Marco Schoolenberg Dec 25 '16 at 01:33

4 Answers4

1

Maybe it could be a WebSphere JAXB issue, related to the version you're using or your server may miss some fixings. Take a look at what the docs say:

The JAXB Unmarshaller generates stub classes at runtime to assist in unmarshalling the document. These generated classes are cached and may be reused by other JAXBContexts in the application.

When a JAXBContext contains a class which has an element wildcard (i.e. @XmlAnyElement) it was possible that the Unmarshaller would use incompatible generated stub classes from another JAXBContext which could result in a ClassCastException being thrown during unmarshalling. The problem was resolved by improving the collision checking done on previously generated stub classes so that a new stub class is generated from the current JAXBContext if the previously generated stub class found in the cache is not compatible.

That's hard to guess because of IBM's nature regardless the version you're using. Also, refer some other fixings:

diogo
  • 3,769
  • 1
  • 24
  • 30
  • Thank you for your answer? Can you please tell me how should I make the check for creating new stubs instead of using the cached ones? – Aditzu Jan 18 '17 at 09:10
1

It seems like problem is on server (or with request).

When Server processes a request, it just makes an echo of it back. Message payload was not changed (for any reason) and no exceptions was thrown.

So when it comes back and unmarshalled it is not instance of SendCustomerCommunicationResponse,but SendCustomerCommunicationRequest

I can suggest first to use SOAPUI (with sample of request) or tcpMon between client and server to see what is exact request and response from server.

Vadim
  • 4,027
  • 2
  • 10
  • 26
1

Q:

  • how is SendCustomerCommunicationResponsedefined? does it include @Xml.. annotations? (eg @XmlRoot ..
  • just for testing, could you set a name for the @WebResult return variable to something different than the name of the return class (SendCustomerCommunicationResponse)
  • what are ServiceException_Exception and SystemException_Exception? your own exceptions? It seems those are JAX-RS/JAXB generated exceptions..
titou10
  • 2,814
  • 1
  • 19
  • 42
1

It looks like a class version mismatch issue.

One of the scenarios where the developers create Web-Service stubs and build them in their project using a newer version whereas the server classpath has an older version of some dependent jar file. I would recommend the following steps to rule out this option of mismatched dependency versions.

  1. Get the dependency tree and for the files which are failing. You should get a list of dependent jar files. (Check specifically the jar file that is responsible for the creation of the Request and Response objects in your local machine)
  2. Compare the classpath of the WebSphere server and add any missing jars.
  3. replace any dependent jar files in the WebSphere classpath if they belong to an older version.

The second approach can be to do a remote debug, if possible, after enabling the de-compiler in your IDE. Check the class files where the exception occurs and ensure that the editor is linked to the navigator view, to ensure that your navigator shows the file in the jar that being debugged. You should be able to find the exact jar file that is invoked at the time of the exception.

Amal Gupta
  • 452
  • 4
  • 13