关于javassist.NotFoundException
2016-04-17 20:47
148 查看
javassist可以用于反射获取方法参数名称,项目中用到,测试用例通过,当发布到tomcat时报错
javassist.NotFoundException: xxx.xxx.xxxService
javassist官网对此有如下说明:
The default ClassPool returned by a static method ClassPool.getDefault() searches the same path that the underlying JVM (Java virtual machine) has. If a program is running on a web application server
such as JBoss and Tomcat, the ClassPoolobject may not be able to find user classes since such a web application server uses multiple class loaders as well as the system class loader. In that case, an additional class path must be registered to the ClassPool.
解决此异常的方法:
1.(推荐)
2.
转自:http://www.codeweblog.com/%E5%85%B3%E4%BA%8Ejavassist-notfoundexception/
javassist.NotFoundException: xxx.xxx.xxxService
ClassPool pool = ClassPool.getDefault(); CtClass cls = pool.get(clazz.getName()); // 此处报异常
javassist官网对此有如下说明:
The default ClassPool returned by a static method ClassPool.getDefault() searches the same path that the underlying JVM (Java virtual machine) has. If a program is running on a web application server
such as JBoss and Tomcat, the ClassPoolobject may not be able to find user classes since such a web application server uses multiple class loaders as well as the system class loader. In that case, an additional class path must be registered to the ClassPool.
解决此异常的方法:
1.(推荐)
ClassPool pool = ClassPool.getDefault(); ClassClassPath classPath = new ClassClassPath(this.getClass()); pool.insertClassPath(classPath);
2.
ClassPool pool = ClassPool.getDefault(); pool.appendClassPath("E:\\xxx\\xxx\\target\\xxx_war\\WEB-INF\\lib\\xxx_jar-0.0.1-SNAPSHOT.jar");
转自:http://www.codeweblog.com/%E5%85%B3%E4%BA%8Ejavassist-notfoundexception/
相关文章推荐
- DBScan聚类算法Java实现
- 20145211 《Java程序设计》第7周学习总结——沧海横流
- 20145235《Java程序设计》第7周学习总结
- Java多线程(4)线程组
- 20145333 《Java程序设计》第二次实验报告
- WebService学习总结(三)——使用JDK开发WebService
- JAVA线程学习笔记
- java初始化顺序
- spring配置方式:
- 20145239杜文超 《Java程序设计》第7周学习总结
- 20145204 《Java程序设计》第7周学习总结
- MyEclipse8.5 安装SVN
- Java学习-9.接口
- 20145322 《Java程序设计》第7周学习总结
- Java学习-8.多态
- 20145317彭垚《Java程序设计》实验二
- 20145307第七周JAVA学习报告
- Java学习-7.复用类
- JAVA代码查错
- Java基础--并发实用工具(4)