NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper 에러

By JS | Last updated: January 02, 2022

NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper 컴파일 에러가 발생했다면, 프로젝트에 jackson-databind 라이브러리가 포함되어있는지 먼저 확인이 필요합니다. jackson-databind 라이브러리에 com.fasterxml.jackson.databind.ObjectMapper 클래스가 정의되어있습니다.

java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
	at retrofit2.converter.jackson.JacksonConverterFactory.create(JacksonConverterFactory.java:40)
  at com.binance.api.client.impl.BinanceApiServiceGenerator.<clinit>(BinanceApiServiceGenerator.java:27)
	at com.binance.api.client.impl.BinanceApiRestClientImpl.<init>(BinanceApiRestClientImpl.java:27)
	at com.binance.api.client.BinanceApiClientFactory.newRestClient(BinanceApiClientFactory.java:101)
	at com.bot.BinanceClientManager.<init>(BinanceClientManager.java:40)
  ...
  at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.lambda$executeRecursively$3(HierarchicalTestExecutor.java:120)
	at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.executeRecursively(HierarchicalTestExecutor.java:108)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$NodeExecutor.execute(HierarchicalTestExecutor.java:79)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:55)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
	at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	... 62 more

해결 방법

Maven을 사용하는 프로젝트라면 pom.xml에 다음과 같이 의존성을 추가하시고 빌드하시면 문제가 해결됩니다. 라이브러리를 추가했는데도 문제가 발생한다면, 프로젝트의 캐시 삭제 및 IDE 툴을 재시작하고 다시 빌드해보시면 문제가 해결될 수도 있습니다.

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.13.1</version>
</dependency>

References

댓글을 보거나 쓰려면 이 버튼을 눌러주세요.
codechachaCopyright ©2019 codechacha