Content Management and Capture

Content Management and Capture

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
Expand all | Collapse all

Class Cast Exception in Multi repository(/unifiedSearch) ICN Search Template : jsonResponse cannot cast to jsonResultSetResponse

  • 1.  Class Cast Exception in Multi repository(/unifiedSearch) ICN Search Template : jsonResponse cannot cast to jsonResultSetResponse

    Posted Fri August 14, 2020 06:33 PM

    Hi Team,

    I am trying to make some changes to the Result set of a multi repository search template in ICN 3.0.5 ifix 007. The jsonResultSetResponse is working in case of the Single repository search template ("/p8/search").

    For a multi repository search, I am using "/unifiedSearch" as the service in the getFilteredServices() method.

    We are fetching the jsonResponse and casting it as:

    JSONResultSetResponse jsonResultSetResponse = (JSONResultSetResponse) jsonResponse;

    However, I am facing Runtime error : com.ibm.ecm.mediator.UnifiedSearchResultsMediator.writeJSONResponse() java.lang.ClassCastException: com.ibm.ecm.json.JSONResponse cannot be cast to com.ibm.ecm.json.JSONResultSetResponse .

    I have also tried to type cast it to the below subclasses:

    JSONClassDefinitionResponse , JSONContentClassesResponse , JSONItemAttributesResponse, JSONViewoneBootstrapResponse and JSONResultSetResponse .

    Same error everytime. Can you also suggest what type of jsonResponse is returning from a Unified Search/multi repository search?

    Thanks in advance.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 2.  RE: Class Cast Exception in Multi repository(/unifiedSearch) ICN Search Template : jsonResponse cannot cast to jsonResultSetResponse

    Posted Mon August 17, 2020 06:57 AM

    Hi,

    I think you can directly handle the JSONObject jsonResponse. For example:

    JSONArray results = (JSONArray) jsonResponse.get("results");

    Thanks,

    Jason



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration


  • 3.  RE: Class Cast Exception in Multi repository(/unifiedSearch) ICN Search Template : jsonResponse cannot cast to jsonResultSetResponse

    Posted Mon August 17, 2020 05:07 PM

    Hi Jason


    Thanks for the hint. It worked!


    In case of a multi repository search, the jsonResponse contains a jsonArray (containing 2 jsonResultSetResponses from respective repositories).


    Case closed. Thanks again.



    #IBMContentNavigator(ICN)
    #Support
    #SupportMigration