java lang NoClassDefFoundError org springframework util MimeType
If you are working with spring framework and while running your code you get exception:
Exception in thread “main” java.lang.NoClassDefFoundError: org/springframework/util/MimeType
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/MimeType at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.springframework.http.converter.ByteArrayHttpMessageConverter.<init>(ByteArrayHttpMessageConverter.java:41) at org.springframework.web.client.RestTemplate.<init>(RestTemplate.java:146) at com.barcap.edt.atlasrisk.dao.delta1.RestServiceTemplate.<clinit>(RestServiceTemplate.java:13) Caused by: java.lang.ClassNotFoundException: org.springframework.util.MimeType at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 15 more
Solution: It means this jar has not been included in your project and this class available in “spring-core-4.1.6.RELEASE.jar”. Please include this jar in your class path and if you are using maven please add below dependency:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.1.6.RELEASE</version> </dependency>
- For further detail please read spring documentation here
Thanks! This solved my problems..