groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Venkat Sadasivam <venkatsa...@gmail.com>
Subject Groovy and Serialization
Date Wed, 16 Nov 2016 15:27:48 GMT
Hello:

We are using Groovy in the web application and some classes loaded via
Groovy script get serialized and added into HttpSession object. In
clustered environment when other Tomcat server try to deserialize we get
ClassNotFoundException.

I tried something like below code in a simple Java.

ScriptEngineManager factory = new ScriptEngineManager(Serialization.class
.getClassLoader());

ScriptEngine engine = factory.getEngineByName("Groovy");

String groovyScript = IOUtils.toString(Serialization.class
.getResourceAsStream("/blah.groovy"), Charset.defaultCharset());

Class<?> myClass = (Class<?>) engine.eval(groovyScript); // this line loads
org.venkat.Blah class

GroovyObject myObj = (GroovyObject) myClass.newInstance();

Serialization.class.getClassLoader().loadClass("org.venkat.Blah"); // this
like shows class not found exception


Is there any way to load Groovy script classes into parent classloader?


Thanks,

Venkat

Mime
View raw message