博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy排查
阅读量:4042 次
发布时间:2019-05-24

本文共 3210 字,大约阅读时间需要 10 分钟。

1、java.lang.ArrayStoreException这个的debug借助IDEA,添加Java Exception的java.lang.ArrayStoreException断点,这样异常时能够看到具体的报错Class

2、首先进入错误debug的是org.springframework.cloud.netflix.eureka.config.EurekaDiscoveryClientConfigServiceBootstrapConfiguration

因为这个版本没有使用远程config,所以ConfigServicePropertySourceLocator的类是找不到,所以报了异常。

继续排查是能发现这个是BootstrapApplicationListener中的bootstrapServiceContext方法处理,异常是忽略的。

这个也是误导了自己,耗时有点长。debug可以看下面2图。

 

3、再次进入的是项目中的GlobalExceptionHandler类,原因也是出在这个类中。

这个类是common模块中的统一异常处理类,其他同事做的权限security,AccessDeniedException在security的jar中。

@ExceptionHandler(AccessDeniedException.class)    public ObjectRestResponse accessDeniedrExceptionHandler(HttpServletResponse response, Exception ex) {        logger.error(ex.getMessage(), ex);        ObjectRestResponse restResponse = new ObjectRestResponse();        restResponse.setStatus(CodeStatus.PARAM_ACCESS_FORBIDDEN.getValue());        restResponse.setMsg(CodeStatus.PARAM_ACCESS_FORBIDDEN.getName());        return restResponse;    }

而该module中的pom进行了exclusion,而yunlian-truck-auth-client模块中间接引用common模块,所以导致GlobalExceptionHandler找不到AccessDeniedException类。

com.sinochem.yunlian.truck
yunlian-truck-auth-client
1.0-SNAPSHOT
org.springframework.boot
spring-boot-starter-security

该异常在refresh方法中进行了throw出来。

 

总结:针对java.lang.ArrayStoreException这样的异常通过IDEA进行进行debug,以及EurekaDiscoveryClientConfigServiceBootstrapConfiguration中的这个异常处理。

---------------------------------------------------------------

具体是java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy 数组越界的异常,为什么是class不存在导致的,是AnnotationParser.parseClassValue把异常包装成为Object。

下面解释来自

仔细看下代码,可以发现AnnotationParser.parseClassValue把异常包装成为Object

//sun.reflect.annotation.AnnotationParser.parseClassValue(ByteBuffer, ConstantPool, Class
) private static Object parseClassValue(ByteBuffer buf, ConstantPool constPool, Class
container) { int classIndex = buf.getShort() & 0xFFFF; try { try { String sig = constPool.getUTF8At(classIndex); return parseSig(sig, container); } catch (IllegalArgumentException ex) { // support obsolete early jsr175 format class files return constPool.getClassAt(classIndex); } } catch (NoClassDefFoundError e) { return new TypeNotPresentExceptionProxy("[unknown]", e); } catch (TypeNotPresentException e) { return new TypeNotPresentExceptionProxy(e.typeName(), e.getCause()); } }

然后在sun.reflect.annotation.AnnotationParser.parseClassArray(int, ByteBuffer, ConstantPool, Class<?>)里尝试直接设置到数组里

// sun.reflect.annotation.AnnotationParser.parseClassArray(int, ByteBuffer, ConstantPool, Class
)result[i] = parseClassValue(buf, constPool, container);

而这里数组越界了,ArrayStoreException只有越界的Object的类型信息,也就是上面的

java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy

 

 

转载地址:http://lgadi.baihongyu.com/

你可能感兴趣的文章
coursesa课程 Python 3 programming 输出每一行句子的第三个单词
查看>>
Returning a value from a function
查看>>
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
查看>>
coursesa课程 Python 3 programming The while Statement
查看>>
course_2_assessment_6
查看>>
coursesa课程 Python 3 programming course_2_assessment_7 多参数函数练习题
查看>>
coursesa课程 Python 3 programming course_2_assessment_8 sorted练习题
查看>>
在unity中建立最小的shader(Minimal Shader)
查看>>
1.3 Debugging of Shaders (调试着色器)
查看>>
关于phpcms中模块_tag.class.php中的pc_tag()方法的含义
查看>>
vsftp 配置具有匿名登录也有系统用户登录,系统用户有管理权限,匿名只有下载权限。
查看>>
linux安装usb wifi接收器
查看>>
多线程使用随机函数需要注意的一点
查看>>
getpeername,getsockname
查看>>
让我做你的下一行Code
查看>>
浅析:setsockopt()改善程序的健壮性
查看>>
关于对象赋值及返回临时对象过程中的构造与析构
查看>>
VS 2005 CRT函数的安全性增强版本
查看>>
SQL 多表联合查询
查看>>
Visual Studio 2010:C++0x新特性
查看>>