简体   繁体   中英

NoClassDefFoundError even though Jar is present in classpath

I'm having a weird issue, I am trying to load the class com.cloudera.impala.jdbc41.Driver using Class.forName("com.cloudera.impala.jdbc41.Driver") but it's throwing exception during runtime. Can someone correct me on what wrong I'm doing here?

java.lang.NoClassDefFoundError: Could not initialize class com.cloudera.impala.jdbc41.Driver

Printing the classpath using the following snippet does print the Jar present in the classpath.

System.out.println(System.getProperty("java.class.path"))

The error message "Could not initialize class" likely means that the class was found, but threw an exception during initialization, perhaps in a static block.

This results in the ClassLoader not being able to "find" the class. Confusing, I know. See if there are any static blocks in this class, and if so, set a debugger breakpoint there to see what's going on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM