返回顶部

收藏

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. coderbee 发表 2017-07-19 14:41:16 Javassist 字节码操作库
  2. obaby 发表 2018-01-04 08:57:51 Javassist
  3. admin 发表 2013-11-13 04:38:59 javassist这货到底干嘛的?
  4. Crazyant 发表 2012-12-26 08:20:07 JSP使用JNA调用DLL函数遇到的几个问题
  5. simonwang 发表 2016-08-21 08:13:48 Java中的Functor与monad
  6. 博主 发表 2011-09-30 20:48:33 Java与JavaScript的回调函数类比
  7. softliumin 发表 2016-09-05 16:32:08 《Apache Zookeeper 官方文档》-3 快速指南:使用zookeeper来协调分布式应用
  8. 郑 旭东 发表 2014-01-16 16:46:51 JAVA多线程和并发基础面试问答
  9. robin 发表 2016-09-11 05:01:30 HttpClient多线程并发
  10. asuncool@gmail.com(轻 发表 2014-02-08 00:58:41 spring mvc jackson 防止XSS 注入方法
  11. 博主 发表 2016-04-09 14:04:08 JAVA SWING第一个窗体应用程序
  12. 黄飞飞 发表 2014-01-29 16:00:56 深入理解Java HelloWorld

发表评论