cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
759
Views
0
Helpful
5
Replies

Accessing User Defined Java Class Object from SessionData - Cisco Call Studio

santoshkt18
Level 1
Level 1

Hello,

The requirement is to store the user defined class object into the session (Cisco Call Studio) and retrieve later. The object gets stored perfectly. However when I try to retrieve it from session using DecisionElementData.getSessionData("UserDefinedClassObject"), It gives me class cast exception. Below is the sample code that I use.

UserDefinedClass udcObject = (UserDefinedClass) DecisionElementData.getSessionData("UserDefinedClassObject"),

Is there a wasy to get around this issue? How can we access the user defined class objects from session ?

I tried serializing (implementing Serializable Interface) the UserDefinedClass but it does not work either. I put the jar file at - project_name/deploy/java/application/lib folder.

Please advice.

Thanks much in advance!

5 Replies 5

ptindall
Cisco Employee
Cisco Employee

You have to access session data via the instantiated object, 'data' in this example below.

public void doAction(String name, ActionElementData data) throws ElementException

{

    String callid = (String) data.getSessionData("callid");

    ...

}


Koen Van Impe
Level 4
Level 4

Santosh,

I had a similar experience 2 years ago. I found that you can save an object in session data, and re-use it later on, as long as there's no voice element with caller interaction in between (like forms, menus). Basically that means you can re-use an object within the same VXML page.

If I saved the objects as session data, had a menu after that, and wanted to re-use the object after the menu, I had the class cast exception as well. For some reason, the java class loader seems to change and that's why we get the exception.

I managed to work around it using serialization. You mention that this doesn't work for you. To what do you serialize?
I serialized to a byte array. Since that is a primitive data type, no issues with class loaders :-)

Rgds,

Koen

Thank you All. When I serialize it to Byte Array it does work. However Is

there a direct way to store and access the custom class objects from the

session. For example I'd like to store custom audio object into session and

later retrieve it directly from the session with getSessionData method ? Is

this possible at all ? Plese let me know.

-Santosh

I'm afraid that whatever object you want to store in session data, there's always a risk you'll meet the class cast exception. (depending on where you store the session data, and want to re-use it later, as explained above).

Maybe someone at Cisco can check why we are meeting this issue. Is it by design? Or can it be fixed under the hood of CVP VXML server?

Rgds,

Koen

I don't get any issue if I put the jar under VXMLServer/common/lib folder.

However when I put it under my "Project/deploy/java/application/lib" folder

, the issue arises.

I'd prefer to have the jar in applicaiton/lib folder rather than common/lib

as it has some advantages. In multi developer environment, each can have

their own version of Jar in their applicaiton. Can any one from Cisco

investigate and let us know if we have quick resolution for this issue ?

(class cast exception for custom object when trying to read from session).

-Thank you,

Santosh