java.lang.ClassCastException: class org.mozilla.javascript.Undefined cannot be cast to class java.la

Rahul Tiwari2
Tera Contributor

while i am using a cartJS in scripted rest api while testing from postman i am getting

error -

java.lang.ClassCastException: class org.mozilla.javascript.Undefined cannot be cast to class java.lang.String (org.mozilla.javascript.Undefined is in unnamed module of loader com.snc.orbit.container.tomcat8.Tomcat8$OrbitTomcat8ClassLoader @ddb5a8; java.lang.String is in module java.base of loader 'bootstrap')
3 REPLIES 3

Community Alums
Not applicable

Seeing this same error after updating our Employee Center application. Any ideas?

Julien Dechard
Tera Contributor

Anyone found a resolution for that topic ? Testing currently the spedint API and getting the same issue ...

Thank you !

hunterphillips
Tera Contributor

I was getting a similar error when passing a catalog item ID to the addToCart() method

var itemId = current.catalog_item;
var cart = new sn_sc.CartJS();

var item = {
	'sysparm_id': itemId,
	'sysparm_quantity': String(quantity || 1),
	'variables': variables
};

cart.addToCart(item);


I needed to make sure that the parameter I was passing was a String

var itemId = current.catalog_item.toString();