Skip to content

fix: 에러 화면이 삭제된 메시지 코드를 참조해 화면 대신 예외가 뜨는 문제 수정 - #46

Merged
jei007 merged 1 commit into
eGovFramework:mainfrom
wantaekchoi:fix/error-view-stale-resource-refs
Sep 3, 2026
Merged

jei007 merged 1 commit into
eGovFramework:mainfrom
wantaekchoi:fix/error-view-stale-resource-refs

Conversation

@wantaekchoi

Copy link
Copy Markdown
Contributor

수정 사유 Reason for modification

소스를 수정한 사유가 무엇인지 체크해 주세요. Please check the reason you modified the source. ([X] X는 대문자여야 합니다.)

  • 버그수정 Bug fixes
  • 기능개선 Enhancements
  • 기능추가 Adding features
  • 기타 Others

수정된 소스 내용 Modified source

검토자를 위해 수정된 소스 내용을 설명해 주세요. Please describe the modified source for reviewers.

문제

에러 화면 두 개가 fc0f784(v5.0.0) 에서 삭제된 자원을 아직 참조합니다.

  • common/error.jsp : 메시지 코드 image.errorBg, 스타일시트 /css/egovframework/sample.css
  • cmmn/dataAccessFailure.jsp : 메시지 코드 fail.common.sql

fc0f784 는 message-common 번들 세 개 모두에서 두 코드를 지웠고 sample.css 도 같이 지웠습니다.

spring:message 는 코드를 찾지 못하면 JspTagException 을 던집니다. 이 프로젝트에는 useCodeAsDefaultMessage 설정이 없고 두 태그에 text= 폴백도 없습니다.

그래서 오류를 보여줄 화면이 스스로 예외를 냅니다. web.xml 의 error-page 세 항목(java.lang.Throwable, 404, 500)이 전부 /common/error.jsp 를 가리키므로 어떤 오류가 나든 사용자에게 앱 화면이 가지 않습니다.

mvn package 로 만든 WAR 를 tomcat:10.1-jdk17-temurin 에 올려 받은 응답입니다.

GET  /noSuchPage.do             -> 404  <title>HTTP Status 404 – Not Found</title>  (톰캣 기본 페이지)
GET  /common/error.jsp          -> 500  0 바이트
POST /addSample.do (name 60자)  -> 500  0 바이트

컨테이너 로그에 남은 원인입니다.

jakarta.servlet.jsp.JspTagException: No message found under code 'image.errorBg' for locale 'en_US'.
org.apache.catalina.core.StandardHostValve.custom Exception Processing [ErrorPage[errorCode=404, location=/common/error.jsp]]
jakarta.servlet.jsp.JspTagException: No message found under code 'fail.common.sql' for locale 'en_US'.

세 번째 요청은 name 을 SAMPLE.NAME 의 VARCHAR(50) 보다 길게 넣은 것입니다. SimpleMappingExceptionResolver 가 DataAccessException 을 cmmn/dataAccessFailure 로 보내는데 그 화면이 예외를 내고, 그 예외가 다시 /common/error.jsp 로 가서 또 예외를 냅니다.

삭제된 코드를 되살리지 않은 이유

image.errorBg 는 문구가 아니라 같은 커밋이 지운 sample.css 의 클래스명이었고, fail.common.sql 은 JSP 가 넘기지 않는 인자를 담고 있어 되살리면 {0}·{1} 이 그대로 나옵니다. 같은 커밋이 남긴 fail.common.msg 는 형제 에러 화면 셋(egovBizException.jsp egovError.jsp transactionFailure.jsp)이 모두 쓰고 있어 두 화면도 거기 맞췄습니다.

수정

  • cmmn/dataAccessFailure.jsp : fail.common.sql 을 fail.common.msg 로 교체
  • common/error.jsp : 삭제된 sample.css 링크 제거, td 의 class 속성 제거, 비어 있던 span 에 fail.common.msg 출력. c:url 이 없어져 쓰이지 않게 된 c taglib 선언도 함께 제거

번들에 없는 코드를 참조하는 화면은 이 두 개입니다.

JUnit 테스트 JUnit tests

테스트를 완료하셨으면 다음 항목에 [대문자X]로 표시해 주세요. When you're done testing, check the following items.

  • JUnit 테스트 JUnit tests
  • 수동 테스트 Manual testing

EgovErrorViewResourceTest 를 함께 넣었습니다. 에러 화면 JSP 다섯 개를 읽어 각 spring:message 코드를 message-common 번들로 한국어와 영어 양쪽에서 실제로 해석해 보고, c:url 로 링크한 정적 자원이 src/main/webapp 아래 있는지 확인합니다.

수정 전에는 다섯 항목을 전부 지목하며 실패합니다. 경로만 줄여 옮깁니다.

EgovErrorViewResourceTest.test  에러 화면이 없는 자원을 참조하면 화면 대신 예외가 뜬다.
[cmmn/dataAccessFailure.jsp : 메시지 코드 fail.common.sql (ko),
 cmmn/dataAccessFailure.jsp : 메시지 코드 fail.common.sql (en),
 common/error.jsp : 메시지 코드 image.errorBg (ko),
 common/error.jsp : 메시지 코드 image.errorBg (en),
 common/error.jsp : 정적 자원 /css/egovframework/sample.css]

수정 후에는 통과합니다. pom.xml 의 surefire skipTests 가 true 로 고정돼 있어 그대로는 실행되지 않으니, 확인하실 때 그 값만 내려 주십시오.

같은 실행에서 EgovSampleControllerTestAddSampleTest 가 HV000183(EL 의존성) 으로 실패하는데, 이 수정과 무관하게 현재 main 에서도 나는 선행 오류입니다.

테스트 브라우저 Test Browser

테스트를 진행한 브라우저를 선택해 주세요. Please select the browser(s) you ran the test on. (다중 선택 가능 you can select multiple) [X] X는 대문자여야 합니다.

  • Chrome
  • Firefox
  • Edge
  • Safari
  • Opera
  • Internet Explorer
  • 기타 Others

브라우저 대신 세션 쿠키를 유지하는 명령행 HTTP 클라이언트로 확인했습니다.

테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video

테스트 전과 후의 스크린샷 또는 캡처 영상을 이곳에 첨부해 주세요. Please attach screenshots or video captures of your before and after tests here.

스크린샷 대신 같은 컨테이너에서 수정 후에 받은 응답을 옮깁니다.

GET  /noSuchPage.do             -> 404  <title>Basic Sample</title>, 본문 "Error Ocurred!"
GET  /common/error.jsp          -> 200  <title>Basic Sample</title>
POST /addSample.do (name 60자)  -> 200  <title>Error</title>, 본문 "Error Ocurred!"

404 는 404 그대로이고 dataAccessFailure 의 200 도 SimpleMappingExceptionResolver 에 statusCode 가 없어 원래 그런 값입니다. 이 수정이 바꾼 것은 상태 코드가 아니라 그려지지 않던 화면이 그려진다는 점입니다.

@jei007 jei007 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

표준프레임워크에 대한 지속적인 참여에
대단히 감사드립니다.

@jei007
jei007 merged commit ccfb212 into eGovFramework:main Sep 3, 2026
1 check passed
@wantaekchoi
wantaekchoi deleted the fix/error-view-stale-resource-refs branch September 3, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants