返回顶部

收藏

javassist javassist.NotFoundException: xxx问题解决

更多

javassist的ClassPool.getCtClass(xx)执行是报错:

08-Feb-2017 16:45:01.386 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_60-ea]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_60-ea]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_60-ea]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_60-ea]
    at com.jd.coo.sa.mybatis.plugins.utils.ReflectionUtils.newInstance(ReflectionUtils.java:94) ~[mybatis-plugins-1.0.6.jar:na]
    ... 77 common frames omitted
Caused by: java.lang.RuntimeException: Can't found class
    at com.jd.coo.sa.mybatis.plugins.pagination.JavassistPageAdaptor.<init>(JavassistPageAdaptor.java:65) ~[mybatis-plugins-1.0.6.jar:na]
    ... 82 common frames omitted
Caused by: javassist.NotFoundException: com.jd.coo.sa.mybatis.plugins.pagination.PageAdapter
    at javassist.ClassPool.get(ClassPool.java:450) ~[javassist-3.19.0-GA.jar:na]
    at javassist.ClassPool.getCtClass(ClassPool.java:515) ~[javassist-3.19.0-GA.jar:na]
    at com.jd.coo.sa.mybatis.plugins.pagination.JavassistPageAdaptor.<init>(JavassistPageAdaptor.java:43) ~[mybatis-plugins-1.0.6.jar:na]
    ... 82 common frames omitted

错误是找不到类, 但是类确实在jar包中存在, 解决此问题的办法是手动将类的ClassPath添加ClassPool中, 如下代码:

Model model = new Model();
ClassPool pool = ClassPool.getDefault();
ClassClassPath ccpath = new ClassClassPath(model.getClass());
pool.insertClassPath(ccpath);
CtClass ctClass = pool.get("com.project.Model");

标签:java,javassist

收藏

1人收藏

支持

1

反对

0

相关聚客文章
  1. obaby 发表 2018-01-04 08:57:51 Javassist
  2. admin 发表 2013-11-13 04:38:59 javassist这货到底干嘛的?
  3. coderbee 发表 2017-07-19 14:41:16 Javassist 字节码操作库
  4. 博主 发表 2015-05-09 20:20:37 详解 Windows 下 Eclipse CDT 配置 C/C++ 编译环境
  5. xirruiqiang 发表 2018-09-06 10:01:16 Spring Boot和Hazelcast使用
  6. 博主 发表 2015-03-27 17:14:55 Getting Java Event Notification Right
  7. 小丁 发表 2018-09-08 23:46:32 Apache Commons Weaver 2.0 发布,最低要求 Java 8
  8. 博主 发表 2015-03-15 12:46:13 异常分析与字符串匹配笔记
  9. xiaoli.he 发表 2018-09-11 12:09:44 Java也谈谈伪共享FlashSharing
  10. 博主 发表 2015-04-20 01:50:51 前后端完全分离初探
  11. 刘莉莉 发表 2018-09-13 09:52:03 线上故障排查(1) – Java应用故障之高CPU占用的问题及排查方案
  12. 魏 鹏 发表 2015-06-02 15:56:15 深入浅出ClassLoader(译)

发表评论