简体   繁体   中英

Unexplained NoClassDefFoundError exception

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/jdbc/core/JdbcTemplate at com.citi.cate.svn.eers.SVNEERSFeeder.loadEmpInfoFromDB(SVNEERSFeeder.java:117) at com.citi.cate.svn.eers.SVNEERSFeeder.process(SVNEERSFeeder.java:523) at com.citi.cate.svn.eers.SVNEERSFeeder.main(SVNEERSFeeder.java:631) at resources.TheApp.main(TheApp.java:39) Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.core.JdbcTemplate at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 4 more

I am unable to find the solution for the above error. lately there was change in the spring-framework version and i changed all the jars related to the new version of spring-framework. i see the above error. tried to reload all the jars.still the error exists. please help me on this.

SVNEERSFeeder.java

line 117: JdbcTemplate jt = new JdbcTemplate(_utility.getDBConnection("csi", ""))

The exception is caused due to misconfiguration of appropriate spring jdbc jars related to the spring version. To resolve dependencies easily, you could use maven: For example, if you are using spring 4.2.5 , add s pring jdbc dependencies in maven as follows:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>4.2.5.RELEASE</version>
</dependency>

Apache Ivy Dependencies:

<dependency org="org.springframework" name="spring-jdbc" rev="4.2.5.RELEASE"/>

NoClassDefFoundError Exception

This exception is thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. This is caused when there is a class file that your code depends on and it is present at compile time but not found at runtime.

Look for differences in your build time and runtime classpaths.

In your case though, it appears that the root cause is:

resources.TheApp.main(TheApp.java:39) Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.core.JdbcTemplate at

ClassNotFoundException

It may be caused when you are trying to make a reflective call to classes at runtime, but the classes the program is trying to call does not exist.

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