Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

Testing banner

Exception occurred java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType

Hi Java Experts,

Hope everyone is doing well in their respective roles.

I have just started learning Java Web Services and it is my first program in Java. My requirement is to make a RMI (Kinaxis RR Scripts) through Web service using Apache Axis2 & rampart . But i'm stuck with this exception. Could some one help me to understand why is this exception is taking a place and how to avoid this.

java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType exception

Here is my Script:

package com.kinaxis.rapidresponse.webservices._1_0_0.rapidresponse;

import org.apache.axis2.client.Options;

import org.apache.axis2.client.ServiceClient;

import java.lang.reflect.ParameterizedType;   

import java.lang.reflect.Type;

import java.lang.ClassCastException;

import com.kinaxis.rapidresponse.webservices._1_0_0.rapidresponse.IService_ExecuteScript_ScriptExecutionFaultFault_FaultMessage;

import com.kinaxis.rapidresponse.webservices._1_0_0.rapidresponse.RapidResponseStub;

import com.kinaxis.rapidresponse.webservices._1_0_0.rapidresponse.RapidResponseStub.ExecuteScript;

import com.kinaxis.rapidresponse.webservices._1_0_0.rapidresponse.RapidResponseStub.ExecuteScriptResponse;

import com.kinaxis.rapidresponse.webservices._1_0_0.rapidresponse.RapidResponseStub.Scope;

public class WebService {

   public static void main(String[] args) throws Exception

{

String userName = "tmangala";

String password = "password";

String endpointAddress = "WsdlAddress";

String scriptName = "UserAccount";

String scriptScope = "Private";

System.out.println("Step1");

try {

if(!scriptScope.equalsIgnoreCase("public") && !scriptScope.equalsIgnoreCase("private")) {

System.out.println("The script scope must be either Public or Private.");

return;

}

System.out.println("Step2");

// Create a binding to the web service.

RapidResponseStub service = null;

if( endpointAddress.length() > 0 ) {

service = new RapidResponseStub(endpointAddress);

} else {

service = new RapidResponseStub("http://rapidresponse.kinaxis.com/Cisco/RapidResponse.ws");

}

// Specify connection parameters

ServiceClient client = service._getServiceClient();

Options options = client.getOptions();

options.setUserName(userName);

options.setPassword(password);

options.setTimeOutInMilliSeconds(20 * 60 * 1000); // 15 minutes

// Engage Rampart for the calls to the service

client.engageModule("rampart");

RapidResponseStub.ExecuteScript esi = new RapidResponseStub.ExecuteScript();

RapidResponseStub.ScriptIdentifier scriptId = new RapidResponseStub.ScriptIdentifier();

//RapidResponseStub.ExecuteScript es=new RapidResponseStub.ExecuteScript();

scriptId.setName(scriptName);

if( scriptScope.equalsIgnoreCase("public") ) {

scriptId.setScope(Scope.Public);

} else {

scriptId.setScope(Scope.Private);

}

//es.Script="UserAccount";

esi.setScript(scriptId);

// Call the web service to execute the script

ExecuteScriptResponse eso = service.executeScript(esi);

// Put out a message with the return code.

System.out.println("The console output of the script was: " + eso.getConsole());

System.out.println("The return value of the script was: " + eso.getValue());

} catch (IService_ExecuteScript_ScriptExecutionFaultFault_FaultMessage e) {

System.out.println("There was an exception encountered");

System.out.println("Code:" + e.getFaultMessage().getScriptExecutionFault().getCode());

System.out.println("Message:" + e.getFaultMessage().getScriptExecutionFault().getMessage());

System.out.println("Console:" + e.getFaultMessage().getScriptExecutionFault().getConsole());

System.out.println("Line:" + e.getFaultMessage().getScriptExecutionFault().getLine());

System.out.println("Character:" + e.getFaultMessage().getScriptExecutionFault().getCharacter());

} catch (Exception e) {

System.out.println("There was an exception encountered");

System.out.println(e.getMessage());

}

}

}

Thanks,

Sreeni

Comments
Post Details
Added on Sep 29 2018
0 comments
484 views