티스토리 뷰

Java

java.lang.ClassNotFoundException

Alledy 2019. 7. 12. 18:59

java.lang.ClassNotFoundException 에러

서버 구동시

java.lang.ClassNotFoundException

심각: 웹 애플리케이션 [/book] 내의 서블릿 [appServlet]이(가) load() 예외를 발생시켰습니다.
java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException

 

pom.xml 파일 내에 에러

Multiple annotations found at this line:

  • schema_reference.4: Failed to read schema document 'https://maven.apache.org/maven-v4_0_0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not xsd:schema.
  • cvc-elt.1: Cannot find the declaration of element 'project'.

 

시도해본 방법

  1. Deployment Assembly 에 메이븐 디펜던시 추가

  2. Project - Clean

  3. context의 네임스페이스 디폴트 버전 확인

  4. .m2/repository 에 있는 파일 전부 삭제 후 프로젝트 폴더 우클릭 - maven - update project

    • 이 방법을 시도하니 pom.xml에 있던 에러는 사라짐

    • 그러나 또 자동으로 jdk 1.6버전으로 되어 에러 나길래 jre library jdk 버전 바꾸고, properties - java complier 에서 컴플라이언스 레벨 1.8로 바꿈

    • 또 다시 에러가 나는데 다른 에러가 남.

      ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed org.springframework.beans.factory.BeanCreationException:

       

    • servlet-context파일에 설정한 컨텍스트 초기화에 실패하였다고 해서 자바 소스를 봤더니 한글이 다 깨져있었음. 즉 리빌드하는 과정에서 인코딩 설정도 초기화돼서 UTF-8로 설정 바꾸어 주었더니 다시 에러 내용이 바뀜

      nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException

       

    • 구글링 결과 jackson 라이브러리를 최신 버전으로 업데이트 하면 해결된다는 것을 보아서 2.9.4버전으로 업데이트

    • <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>2.9.4</version>
      </dependency>
      
    • 에러 해결!!!! databind-annotation-core 3개의 의존성 버전이 달라서 일어나는 문제라고 한다.

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함