본문 바로가기

📝 ErrorNote

[Error] Execution failed for task ':ServletApplication.main()'.> Process 'command '/Users/gangminhui/Library/Java/JavaVirtualMachines/corretto-17.0.9/Contents/Home/bin/java'' finished with non-zero exit value 1

평온하게 개발 공부를 하던 중 에러가 발생했다. 

 

갑자기 왜 애플리케이션을 작동시키지 못하는 것인가? 

 

왜 빌드 실패를 하는 가? 

Execution failed for task ':ServletApplication.main()'.
> Process 'command '/Users/gangminhui/Library/Java/JavaVirtualMachines/corretto-17.0.9/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 1s
3 actionable tasks: 1 executed, 2 up-to-date

 

 

해결해보자 

 

일단 무슨 에러인지 감을 잡을 수 없는 실행 창이었다. 

 

이를 위해 해준 것은 

 

1. 빌드 및 실행 방식 변경 

Gradle > IntelliJ IDEA  로 변경해주었다. 

 

그러자 

 

 

이렇게 에러 메시지가 출력되었다. 

 

설명을 읽어보면 mvcMemberServlet 이 이미 정의되어있어서 등록할 수 없다는 말이었다. 

 

Action에는 저렇게 설명하라고 하지만 사실 난 실수로 Servlet 을 같은 이름을 두 개를 등록해놓은 상태였다. 

 

오 엠 즤... 

 

당연히 서블릿 이름이 중복이라 에러가 날 수 밖에 없는데 

이걸 발견 못하고 Gradle 버전 문제인 줄 알고 한참 시간을 허비했다. ㅎㅎ 

 

그래도 빌드 및 실행을 바꾸니 에러 메시지가 명확하게 출력되어 도움이 되었다. 

 

2. 서블릿 이름 중복 수정하기 

 

 

 

 

서블릿 이름 바꿔주니... 오잉? 

 

다시 또 다른 에러가 났다. 

 

 

다시 Gradle 로 바꿔주자 

 

3. Gradle 로 다시 변경

 

정상적으로 작동! ㅎㅎ 

 

 

그냥 서블릿 네임이 겹쳤던 것 뿐이었고, 빌드 및 실행은 원래대로 Gradle로 해주는 것이 맞다. 

 

저것을 intelliJ IDEA 로 하면 실행 속도가 조금 더 빨라지는 장점이 있다고 하는데

무료 커뮤니티 버전을 사용하는 경우에는 Gradle로 설정해줘야 한다고 들었다.