AnsweredAssumed Answered

Help! With DevTest 9.1, getting java.lang.ClassCastException:

Question asked by paul.yeung on Jun 30, 2016
Latest reply on Jul 6, 2016 by paul.yeung


Hi all,

 

I have been using the previous versions of DevTest/LISA 7.5 and 8 with no problems whenever I write a custom Java Script Step. Usually it's because I want to grab some value from a Web Services request (usually SOAP). Here is my simple code below:

 

import com.itko.lisa.vse.stateful.model.Request;

import com.itko.util.ParameterList;

import com.itko.lisa.VSE;

try

{

     //testExec.setStateValue("newRefID", "blah blah");

 

    Request reqRequest = (Request) testExec.getStateValue("lisa.vse.request");

    ParameterList plArguments = reqRequest.getArguments();

    String PermID =  plArguments.getParameterValue("CustId_CustPermId");

  

    testExec.setStateValue("newRefID", PermID);

    return true;

  

}

catch (Exception err) {

    testExec.log("Exception occurred while trying to retrieve service request", "Details ::: " + err.toString());

    return false; 

}

 

Please note the first line is commented out, I used it previously for testing and it will work perfectly fine when un-commented out. (   {{newRefID}} is successfully replaced with "blah blah" in the response ).

Currently, when I run ITR, there will be a response, but my {{newRefID}} remains unchanged and is displayed as {{newRefID}} instead of the request parameter. When I check the test events in the Java Script I see the error message below:

 

Details ::: java.lang.ClassCastException: Cannot cast java.lang.String to com.itko.lisa.vse.stateful.model.Request

 

I believe that once I have "Request reqRequest = (Request) testExec.getStateValue("lisa.vse.request");" it actually just throws an exception and gets caught internally, not allowing the lines afterwards to be executed. On a side note, it doesn't matter if I had the (Request) type cast there or not, either way does not work in 9.1.

 

What has changed in 9.1? I have been using this (and very similar) code in previous versions and I have never had this issue. Is there a new way I should be grabbing parameters?

Outcomes