Skip to content

🚨 [Bug] NullPointerException 발생 (jwtAuthenticationFilter) #11

@Kim-Yukyung

Description

@Kim-Yukyung

📌 문제 설명
jwtAuthenticationFilter가 초기화될 때 logger가 null이 되어 NullPointerException이 발생
해당 오류는 AOP 기반의 예외 로깅 기능(logExceptions)을 추가한 이후 발생


🛠️ 구현 방법
Logging AOP 클래스에 아래 코드를 추가함

@Around("within(com.sayup.SayUp..*)")
public Object logExceptions(ProceedingJoinPoint joinPoint) throws Throwable {
    try {
        return joinPoint.proceed();
    } catch (Exception e) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        String methodName = signature.getMethod().getName();
        String className = signature.getDeclaringType().getSimpleName();

        logger.error("Exception in {}.{}() | Error: {}", className, methodName, e.getMessage(), e);

        throw e;  // 예외 다시 던지기
    }
}

애플리케이션 실행 시, jwtAuthenticationFilter 초기화 과정에서 logger가 null이 되어 NullPointerException 발생


📄 에러 로그
ERROR 5544 --- [SayUp] [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Exception starting filter [jwtAuthenticationFilter]
java.lang.NullPointerException: Cannot invoke "org.apache.commons.logging.Log.isDebugEnabled()" because "this.logger" is null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions