History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: MCHECKSTYLE-10
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: fabrizio giustina
Reporter: Nick Giles
Votes: 2
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Maven 2.x Checkstyle Plugin

Exception when creating Checkstyle report as part of a 'site' build

Created: 16/Dec/05 03:42 AM   Updated: 08/Mar/06 10:46 PM
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.0

Time Tracking:
Not Specified

File Attachments: 1. Text File error_trace.txt (4 kb)

Environment: Windows XP, JDK 1.4.2_10, Maven 2.0.2-SNAPSHOT, maven-checkstyle-plugin 2.0-beta-2-SNAPSHOT
Issue Links:
Related
dependent
 


 Description  « Hide
When attempting to create a project site including a checkstyle report, the build fails with the attached stack trace. However, when creating a checkstyle report simply by running 'mvn checkstyle:checkstyle', the build is successful and the report is produced.

From some initial investigation, it appears that the classloader passed in to checkstyle itself by the plugin can locate essential resources when the build is specifically for checkstyle, but cannot locate them when it is invoked as part of a call for 'site'. This can be tested by adding the following lines of code into org.apache.maven.plugin.checkstyle.CheckstyleReport.getModuleFactory(), where 'loader' is the ClassLoader being passed to the PackageNamesLoader:

getLog().info("\n\n\n\nClass loader: " + loader.getClass().getName());
getLog().info("Input stream: " + loader.getResourceAsStream("com/puppycrawl/tools/checkstyle/checkstyle_packages.xml"));
getLog().info("DTD: " + loader.getResourceAsStream("com/puppycrawl/tools/checkstyle/packages_1_0.dtd"));

These should show jar file URLs if found, and null if not, which will happen respectively when run as 'mvn checkstyle:checkstyle' and 'mvn site'.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Fabrice BELLINGARD - 27/Dec/05 08:14 AM
I get exactly the same problem. This breaks the site generation when adding Checkstyle as a report. I'd say that this bug is critical for the Checkstyle plugin, as having the report in the site is its major feature.

Carlos Sanchez - 27/Dec/05 09:08 AM
I'm getting something a bit different with the last version from svn
checkstyle:checkstyle succeeds but site fails

org.apache.maven.lifecycle.LifecycleExecutionException: Error during report generation
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:472)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error during report generation
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:434)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:414)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:531)
... 16 more
Caused by: org.apache.maven.reporting.MavenReportException: Failed during checkstyle configuration
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:461)
at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:98)
at org.apache.maven.plugins.site.SiteMojo.generateReportsPages(SiteMojo.java:922)
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:361)
... 18 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: unable to read default package names
at com.puppycrawl.tools.checkstyle.PackageNamesLoader.loadModuleFactory(PackageNamesLoader.java:198)
at com.puppycrawl.tools.checkstyle.PackageNamesLoader.loadModuleFactory(PackageNamesLoader.java:146)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.getModuleFactory(CheckstyleReport.java:823)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:455)
... 21 more
Caused by: java.net.MalformedURLException
at java.net.URL.<init>(URL.java:601)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:968)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:184)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at com.puppycrawl.tools.checkstyle.api.AbstractLoader.parseInputSource(AbstractLoader.java:96)
at com.puppycrawl.tools.checkstyle.PackageNamesLoader.loadModuleFactory(PackageNamesLoader.java:184)
... 24 more


Carlos Sanchez - 27/Dec/05 12:17 PM
Workaround:

Add extensions to your build section

<extensions>
<extension>
<groupId>checkstyle</groupId>
<artifactId>checkstyle</artifactId>
<version>4.1</version>
</extension>
</extensions>

unfortunately that causes another problem

[INFO] org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
[INFO] ----------------------------------------------------------------------------
[DEBUG] Trace
org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:246)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
at org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:130)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.createBeanUtilsBean(AutomaticBean.java:73)
at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:150)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeCheckstyle(CheckstyleReport.java:632)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:457)
at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:98)
at org.apache.maven.plugins.site.SiteMojo.generateReportsPages(SiteMojo.java:922)
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:361)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:414)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:531)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:472)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525)
... 29 more
Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:412)
... 30 more


Carlos Sanchez - 27/Dec/05 12:22 PM
Joakim thinks that this issue is related to MNG-1896

fabrizio giustina - 30/Dec/05 05:01 AM
The plugin has been fixed by manually switching the context classloader (note: checkstyle will always use the context classloader for resources).
Please give it a try: also if the issue dependes on a maven core issue we will probably need to leave this hack in for backward compatibility.

fabrizio giustina - 30/Dec/05 09:48 AM
Tested on different projects and it seems to work properly with the latests patches. Closing