checkstyle问题:解决Got an exception - java.lang.RuntimeException: Unable to get class information for ***Exception


解决Got an exception - java.lang.RuntimeException: Unable to get class information for ***Exception.

[中文解决方法]

有这样错误的原因是因为没有把该excepiton使用的jar包加入到classpath中.
我出现了两个Exception的错误:ServletException(在servlet-api.jar中),ModuleException(自己定义的java类).

 <target name="checkstyle" depends="junitreport">
  <checkstyle config="${checkstyle.config}">
   <classpath>
                                <!-- 找到存放servlet-api.jar的目录 -->
    <path refid="classpath" />
                                <!-- 找到存放ModuleException.class的jar文件 -->
    <path location="${jar.name}" />
   </classpath>
   <fileset dir="${src.dir}" includes="**/*.java" />
   <fileset dir="${test.dir}" includes="**/*.java" />
   <formatter type="plain" />
   <formatter type="xml" toFile="${checkstyle.dir}/checkstyle_errors.xml" />
  </checkstyle>
 </target>

加上<classpath>后,就build成功了.
找这个解决方法找了一个晚上,希望能对你有帮助!


[english solution]

I have got this problem. I used the ant to call checkstyle, then I got the problem:Got an exception - java.lang.RuntimeException: Unable to get class information for @throws tag 'ServletException'.
The cause is that checkstyle can't find out the exception class in classpath. So It only needs to add the jar of the exception class to the classpath. For example:

<checkstyle config="${tools.checkstyle.ruleset}" failOnViolation="false" failureProperty="checkstyle.failure">
<classpath>
<path refid="classpath.project.lib" />
<path refid="classpath.tools.libs" />
<path refid="classpath.catalina" />
</classpath>
<formatter type="xml" tofile="${report.checkstyleReport.xml}" />
<fileset dir="${project.src}" includes="*/.java" />
</checkstyle>

I add the <path> in classpath, it will run successfully.

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值