From: Jimmy M. <jim...@gm...> - 2016-05-20 00:22:07
|
For context, see sample project in: https://github.com/ElCubanoPoderoso/jython-classloader-issue I have a use-case where I must support dynamically loaded .jar files as hot-deployable subapplications. I was having trouble in instances where if the .jar file was redeployed (say I made a code change and need to update the environment), Jython starts to break down with class casting. Upon the first deployment, the application is able to properly load the .jar file, instantiate the main class which creates the interpreter with the packaged URLClassLoader into the PySystemState object, interprets the script and creates the class object with the appropriate java interface cast to it. However, the second invocation of said project causes the casting to fail on subsequent executions, converting the object to a PySingleton and rejecting the cast. I'm having trouble understanding what I need to do to resolve my issue. Not being able to properly coerce the object to the expected java interface is causing forced workarounds to add wrapper objects to utilize them in Java code. Note: This is only observed when trying to cast to interfaces that reside inside the .jar file and not in the system classloader. The sample GitHub project linked was simplified to generate a proof-of-concept that can be invoked via JUnit to reproduce the error. My question is: what is wrong with my current implementation that is causing this issue? As part of the requirement, I must be able to redeploy without shutting down the JVM. Any help in this matter would be appreciated. Thanks, ~Jimmy M. |