项目添加Maven支持后,单元测试报异常解决
作者:网络转载 发布时间:[ 2013/7/26 10:08:37 ] 推荐标签:
项目添加Maven支持后,运行JUnit单元测试,出现一下错误:
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type
[com.travelsky.tdp.pkgStock.integration.logback.appender.mail.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type
com.travelsky.tdp.pkgStock.integration.logback.appender.mail.SMTPAppender
at ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com.travelsky.tdp.pkgStock.integration.logback.appender.mail.SMTPAppender
at at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:54)
at ......(省略打印信息)
at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/internet/AddressException
at at java.lang.ClassLoader.defineClass1(Native Method)
at .....(省略打印信息)
at ... 41 common frames omitted
ERROR in ch.qos.logback.core.joran.spi.Interpreter@192:115 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException:
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com.travelsky.tdp.pkgStock.integration.logback.appender.mail.SMTPAppender
at ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type
com.travelsky.tdp.pkgStock.integration.logback.appender.mail.SMTPAppender
at at ch.qos.logback.core.joran.action.AppenderAction.begin(AppenderAction.java:82)
at ......(省略打印信息)
at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com.travelsky.tdp.pkgStock.integration.logback.appender.mail.SMTPAppender
at at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:54)
at ... 39 common frames omitted
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file <SPAN style="COLOR: #ff0000"><STRONG>javax/mail/internet/<SPAN style="COLOR: #ff0000">Ad</SPAN>dressException</STRONG></SPAN>
at at java.lang.ClassLoader.defineClass1(Native Method)
at .....(省略打印信息)
at ... 41 common frames omitted
单元测试失败,查找原因,发现如下问题:
1、Maven依赖中使用的 javeee.jar 版本较高,里面包含了 mail相关的接口,和 mail.jar 相冲突;
2、javaee.jar 中包含了 mail相关接口的 实现类;
3、MyEclipse自带的javaee.jar 版本和 MyEclipse本身的版本有关:MyEclipse6.5自带的javaee.jar 中不包含mail相关的接口,而MyEclipse8.0自带的javaee.jar中包含了mail相关的接口,同时包含了接口的实现;
4、项目中直接用到了mail.jar中的类和方法;
此bug出现的原因是由于类冲突,因此去掉冲突的类即可;但是应该怎么选择呢?
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11