자바
[자바] ClassNotFoundException: Licensed to the Apache Software Foundation (ASF) under one or more
imcoding
2022. 12. 6. 20:21
현상
java.lang.ClassNotFoundException: # Licensed to the Apache Software Foundation (ASF) under one or more
컨트롤러에서 jsp 호출 시 위 에러 발생. 오류코드는 500.
대충 번역기 돌리면 "하나 이상의 Apache Software Foundation(ASF)에 라이센스 부여됨" 이라는 의미다.
로그를 찍어보니 컨트롤러는 정상적으로 호출되므로, jsp로 넘어가면서 어떤 문제가 발생했다고 볼 수 있다.
해결
아래 코드 처럼 maven 의존성에 provided 스코프 부분을 추가하여 해결했다.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
원인
provided가 뭔지 찾아보고자 공식문서를 보면 다음과 같다.
this is much like compile, but indicates you expect the JDK or a container to provide it at runtime. It is only available on the compilation and test classpath, and is not transitive.
maven pom 공식문서 (들어가서 컨트롤 F -> provided)
쉽게 말해, 컴파일 시점에는 필요하나 런타임에서는 JDK 혹은 컨테이너가 제공하는 것들이다.
provided가 명시된 것들은 컴파일과 테스트 클래스패스 용도로 사용되고 이것들은 런타임 등 다른 곳으로 transitive 되지않는다.
이 것을 토대로 위 에러가 발생한 이유를 추측하자면, 컴파일 시 해당 의존성이 필요했지만, 런타임 진입 시 자동으로 제공되는 것이다.
그런데 provided를 명시하지 않아 런타임에서 이중으로 의존성이 부여되어 발생한 에러라는 것을 알 수 있다.