解决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.