Resttemplate bean created in springboot accessed in bpmn is not working in bpmn

I have defined a bean named restBean1 for class of type resttemplate.
if I try to save it camunda variable just to verify the accessibility with execution.setVariable(“var1”,restBean1.toString()) - i can see the object getting stored
but when I try to do restBean1.getForEntity(‘url’,String.class)
i get unable to evaluate script

**java.lang.ClassCastException : Cannot cast jdk.nashron.internal.runtime.Underfined to java.lang.class at java.base/java.lang.Class.case(Class.java)

Having script type as javascript for below snippet
restBean1.getForEntity(‘url’,String.class)
was causing the error mentioned above as String.class was not recognised by javascript

updating it as below format worked
restBean1.getForEntity(‘url’,Java.type(‘java.lang.String’).class

Thanks for posting your solution.