Problem while configuring a new custom check

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem while configuring a new custom check

kkforums
Hi All,

I have one requirement to extend Checkstyle with custom checks for my project.

I have tried to run / configure  one example and it didn't get through.

Please find the details below.

Please find the Java source file which has been attached.

Configuration file is as follows:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "D:/configuration_1_2.dtd">
<module name="Checker"> 
  <module name="TreeWalker">   
    <module name="ThrowsRException"/>
   </module>   
</module>

The command i have used to run the example is:

java -classpath D:\checkstyle-5.0\checkstyle-all-5.0.jar com.puppycrawl.tools.checkstyle.Main -c D:\PluginsWorkspace\Plugin\src\com\abc\plugin\custom_check.xml D:\PluginsWorkspace\Plugin\src\com\abc\plugin\TestCaseException.java

And finally the error log is:

Unable to create Checker: cannot initialize module TreeWalker - Unable to instan
tiate com.abc.plugin.ThrowsRException
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize modul
e TreeWalker - Unable to instantiate com.abc.plugin.ThrowsRException
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:177)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(Automatic
Bean.java:207)
at com.puppycrawl.tools.checkstyle.Main.createChecker(Main.java:138)
at com.puppycrawl.tools.checkstyle.Main.main(Main.java:115)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to in
stantiate com.abc.plugin.ThrowsRException
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(Pac
kageObjectFactory.java:156)
at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java
:159)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(Automatic
Bean.java:207)
at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:156)
... 3 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Unable to in
stantiate com.abc.plugin.ThrowsRExceptionCheck
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.doMakeObject(Pac
kageObjectFactory.java:99)
at com.puppycrawl.tools.checkstyle.PackageObjectFactory.createModule(Pac
kageObjectFactory.java:153)
... 6 more


Please let me know if anyone has any clue.
ThrowsRException.java
P.S. I hope that it is a configuration problem OR the way i have been trying to run the Check is a problem.

Thanks and Regards
Kiran