dimanche 7 août 2016

java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder

I am loading a java class from jar through reflection, normal core java code is working fine but while i am integrating this code with Spring i am getting

java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder
exception

even though i have added the protobuf-java-2.5.0 dependency in POM.xml as well. following is the sample code:

File jarFile = new File(jarPath);
URL url = jarFile.toURI().toURL();
URL[] urls = new URL[] { url };
ClassLoader classLoader = new URLClassLoader(urls);
Class<?> loadedMyClass = classLoader.loadClass(className);
Class[] innerClass = loadedMyClass.getDeclaredClasses();

It is throwing exception in the following line:

Class[] innerClass = loadedMyClass.getDeclaredClasses();

Could anyone help me out to fix this issue?





Aucun commentaire:

Enregistrer un commentaire