ClassNotFoundException when using expression to dispatch to an action
Fix class loading exception in condition evaluator
@@ -82,6 +82,9 @@ public class ActionExecutorDispatcher {
valueExtractors.put("script", new ValueExtractor() {
@Override
public Object extract(String valueAsString, Event event) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
if (!mvelExpressions.containsKey(valueAsString)) {
ParserConfiguration parserConfiguration = new ParserConfiguration();
parserConfiguration.setClassLoader(getClass().getClassLoader());
@@ -92,6 +95,9 @@ public class ActionExecutorDispatcher {
ctx.put("session", event.getSession());
ctx.put("profile", event.getProfile());
return MVEL.executeExpression(mvelExpressions.get(valueAsString), ctx);
+ } finally {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
}
});
}
