Java – Eclipse plugin project “checkstyle internal error” says “cannot initialize module TreeWalker – Unable to instantiate ‘…ForbidCertainImportsCheck'”

checkstyleeclipseeclipse-pluginjava

I haven't looked at my Eclipse plugin project for a few weeks, but after I updated to Neon.1, I noticed the following error in the Problems view:

Checkstyle execution failed due to an internal error. Please check the error log for details.

In the error log, I saw things like this:

!MESSAGE Checkstyle-Plugin: cannot initialize module TreeWalker – Unable to instantiate
'com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheck' class,
it is also not possible to instantiate it as com.puppycrawl.tools.checkstyle.checks.annotation.com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheck,
com.puppycrawl.tools.checkstyle.checks.blocks.com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheck,
[deleted numerous similar class names],
com.puppycrawl.tools.checkstyle.com.github.sevntu.checkstyle.checks.coding.ForbidCertainImportsCheckCheck.
Please recheck that class name is specified as canonical name or read how to configure short
name usage http://checkstyle.sourceforge.net/config.html#Packages. Please also
recheck that provided ClassLoader to Checker is configured correctly.

After I saw this in my neon.1 workspace, I also noticed that my older workspace running in Mars.2 was also showing the same problem.

Best Answer

I've managed to resolve this.

The parent POM of the project I work on had a change to its checkstyle configuration, and it now requires adding the "seventu" auxiliary checkstyle plugin, which I found at https://github.com/sevntu-checkstyle/sevntu.checkstyle . Once I installed that (and did the usual "Maven Update Projects" invocation), the errors went away.