Hi.
I have found another work around.
I change thread context classloader to parent classloader before proxy
method invoke and swich it back after.
So the code look like this:
public class ServiceHelper {
public static <T> T serviceMethodInvoke(Object service, final String
methodName, final Object... args) {
ClassLoader initClassloader =
Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getCorrectClassloader(initClassloader));
try {
Method method = service.getClass().getMethod(methodName,
Arrays.stream(args).map(Object::getClass).toArray(Class[]::new));
if (service instanceof GridServiceProxy) {
return (T) ((GridServiceProxy) service).invokeMethod(method,
args);
} else {
return (T) method.invoke(service, args);
}
} catch (NoSuchMethodException | IllegalAccessException |
InvocationTargetException e) {
throw new IllegalStateException("Error while method invoke: " +
methodName, e);
} finally {
Thread.currentThread().setContextClassLoader(initClassloader);
}
}
private static ClassLoader getCorrectClassloader(ClassLoader
initClassloader) {
ClassLoader correctClassloader = initClassloader;
while (correctClassloader.getParent() != null &&
correctClassloader.getClass().getName().equals("org.apache.ignite.spi.deployment.uri.GridUriDeploymentClassLoader"))
{
correctClassloader = correctClassloader.getParent();
}
return correctClassloader;
}
}
But I don't understand what do you mean by "locally-deployed job with same
dependency"?
Your sincerely, Dmitry.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/