diff --git a/intc-admin/Dockerfile b/intc-admin/Dockerfile index ddc2149..e0c7b86 100644 --- a/intc-admin/Dockerfile +++ b/intc-admin/Dockerfile @@ -5,6 +5,12 @@ FROM openjdk:17 LABEL maintainer="Intc" +# 安装字体库,解决验证码生成时的字体加载问题 +RUN apt-get update && apt-get install -y \ + fontconfig \ + fonts-dejavu-core \ + && rm -rf /var/lib/apt/lists/* + RUN mkdir -p /intc/server/logs \ /intc/server/temp \ /intc/skywalking/agent diff --git a/intc-common/intc-common-web/src/main/java/com/intc/common/web/handler/GlobalExceptionHandler.java b/intc-common/intc-common-web/src/main/java/com/intc/common/web/handler/GlobalExceptionHandler.java index 08b1b31..4259e4c 100644 --- a/intc-common/intc-common-web/src/main/java/com/intc/common/web/handler/GlobalExceptionHandler.java +++ b/intc-common/intc-common-web/src/main/java/com/intc/common/web/handler/GlobalExceptionHandler.java @@ -28,6 +28,7 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchExcep import org.springframework.web.servlet.NoHandlerFoundException; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; /** * 全局异常处理器 @@ -140,6 +141,41 @@ public class GlobalExceptionHandler { public void handleRuntimeException(AsyncRequestTimeoutException e) { } + /** + * 反射调用异常(InvocationTargetException) + * 解包获取真正的异常原因 + */ + @ExceptionHandler(InvocationTargetException.class) + public R handleInvocationTargetException(InvocationTargetException e, HttpServletRequest request) { + String requestURI = request.getRequestURI(); + Throwable targetException = e.getTargetException(); + if (targetException != null) { + log.error("请求地址'{}',反射调用发生异常: {}", requestURI, targetException.getMessage(), targetException); + return R.fail(targetException.getMessage()); + } + log.error("请求地址'{}',反射调用发生未知异常.", requestURI, e); + return R.fail("系统内部错误,请联系管理员"); + } + + /** + * InternalError 异常处理 + * 通常由底层JVM错误或反射调用错误引起 + */ + @ExceptionHandler(InternalError.class) + public R handleInternalError(InternalError e, HttpServletRequest request) { + String requestURI = request.getRequestURI(); + Throwable cause = e.getCause(); + if (cause instanceof InvocationTargetException) { + Throwable targetException = ((InvocationTargetException) cause).getTargetException(); + if (targetException != null) { + log.error("请求地址'{}',发生系统内部错误(InvocationTargetException): {}", requestURI, targetException.getMessage(), targetException); + return R.fail(targetException.getMessage()); + } + } + log.error("请求地址'{}',发生系统内部错误: {}", requestURI, e.getMessage(), e); + return R.fail("系统内部错误: " + (e.getMessage() != null ? e.getMessage() : "请联系管理员")); + } + /** * 拦截未知的运行时异常 */