I have a Spring boot Project which Contains a DTO object. In one of our Jar we have a program to Read a file and create the DTO object. I am trying to load the DTO through Reflection. Its working perfectly from local eclipse workspace but when I deploy it in the cloud it fails, giving class not found exception. The below code is in the Jar which is added as maven dependendy.
public class AbcFileReader<T extends ReaderInterface>{
public List<T> readFile(File, String className){
T newObj = (T)Class.forName(className).newInstance();
}
Here className = "com.abc.dto.AbcDTO";
Its implements ReaderInterface.java and the class is present in the package. I have also tried the below line. But not working on cloud.
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
T newObj = (T)Class.forName(className,true, contextCL).newInstance();
Aucun commentaire:
Enregistrer un commentaire