[ https://jira.codehaus.org/browse/MCHECKSTYLE-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=364916#comment-364916 ]
J L commented on MCHECKSTYLE-250: --------------------------------- {{mvn test-compile checksytle:check}} no longer results in an NPE, but runs into MCHECKSTYLE-225. :S {code} [ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.15-SNAPSHOT:check (default-cli) on project server: Failed during checkstyle execution: Failed during checkstyle configuration: unable to read /path/to/server/target/checkstyle-checker.xml - unable to parse configuration stream - Property ${checkstyle.header.file} has not been set -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.15-SNAPSHOT:check (default-cli) on project raptor-server: Failed during checkstyle execution at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216) at org.apache.maven.cli.MavenCli.main(MavenCli.java:160) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Failed during checkstyle execution at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:539) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 19 more Caused by: org.apache.maven.plugin.checkstyle.exec.CheckstyleExecutorException: Failed during checkstyle configuration at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.getConfiguration(DefaultCheckstyleExecutor.java:450) at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:218) at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:530) ... 21 more Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: unable to read /Users/julio/devel/all/cloud-test/raptor-server/target/checkstyle-checker.xml - unable to parse configuration stream - Property ${checkstyle.header.file} has not been set at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:346) at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:286) at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.getConfiguration(DefaultCheckstyleExecutor.java:381) ... 23 more Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: unable to parse configuration stream - Property ${checkstyle.header.file} has not been set at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:410) at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:338) ... 25 more Caused by: org.xml.sax.SAXException: Property ${checkstyle.header.file} has not been set at com.puppycrawl.tools.checkstyle.ConfigurationLoader$InternalLoader.startElement(ConfigurationLoader.java:158) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at com.puppycrawl.tools.checkstyle.api.AbstractLoader.parseInputSource(AbstractLoader.java:99) at com.puppycrawl.tools.checkstyle.ConfigurationLoader.parseInputSource(ConfigurationLoader.java:273) at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:397) ... 26 more [ERROR] {code} > NPE on tying to load LICENSE.txt resource from non-jar plugin dependencies > -------------------------------------------------------------------------- > > Key: MCHECKSTYLE-250 > URL: https://jira.codehaus.org/browse/MCHECKSTYLE-250 > Project: Maven Checkstyle Plugin > Issue Type: Bug > Affects Versions: 2.13 > Reporter: Konstantin Pokrovsky > > *Steps to reproduce:* > * Add non jar (XML for example) artifact dependency to plugin dependencies > section: > {code:xml} > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-checkstyle-plugin</artifactId> > <version>2.13</version> > <dependencies> > <dependency> > <groupId>anygroup</groupId> > <artifactId>anyfile</artifactId> > <type>xml</type> > </dependency> > </dependencies> > </plugin> > {code} > * Run _checkstyle:check_ > Result: > {noformat} > [ERROR] Failed to execute goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (default-cli) on > project rt: Execution default-cli of goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check failed. > NullPointerException -> [Help 1] > org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute > goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check > (default-cli) on project rt: Execution default-cli of goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check failed. > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) > at > org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) > at > org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) > at > org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) > at > org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317) > at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152) > at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) > at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) > at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at > org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) > at > org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) > at > org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) > at > org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) > Caused by: org.apache.maven.plugin.PluginExecutionException: Execution > default-cli of goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check failed. > at > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) > ... 19 common frames omitted > Caused by: java.lang.NullPointerException: null > at > org.codehaus.plexus.resource.loader.JarHolder.getEntries(JarHolder.java:126) > at > org.codehaus.plexus.resource.loader.JarResourceLoader.loadJar(JarResourceLoader.java:100) > at > org.codehaus.plexus.resource.loader.JarResourceLoader.initialize(JarResourceLoader.java:63) > at > org.codehaus.plexus.resource.loader.JarResourceLoader.getResource(JarResourceLoader.java:141) > at > org.apache.maven.plugin.checkstyle.resource.LicenseResourceManager.getResource(LicenseResourceManager.java:75) > at > org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsFile(DefaultResourceManager.java:91) > at > org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.getOverridingProperties(DefaultCheckstyleExecutor.java:520) > at > org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.getConfiguration(DefaultCheckstyleExecutor.java:347) > at > org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:220) > at > org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:532) > at > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) > ... 20 common frames omitted > {noformat} > *Investigation:* > * _CheckstyleViolationCheckMojo_ forms _CheckstyleExecutorRequest_ for the > executor by initializing _licenseArtifacts_ property with all plugin's > dependencies. > {code:java|title=CheckstyleViolationCheckMojo.java:516} > request.setConsoleListener( getConsoleListener() > ).setConsoleOutput( consoleOutput ) > .setExcludes( excludes ).setFailsOnError( failsOnError > ).setIncludes( includes ) > .setResourceIncludes( resourceIncludes ) > .setResourceExcludes( resourceExcludes ) > .setIncludeResources( includeResources ) > .setIncludeTestResources( includeTestResources ) > .setIncludeTestSourceDirectory( > includeTestSourceDirectory ).setListener( getListener() ) > .setLog( getLog() ).setProject( project > ).setSourceDirectories( getSourceDirectories() ) > .setResources( resources ) > .setStringOutputStream( stringOutputStream > ).setSuppressionsLocation( suppressionsLocation ) > .setTestSourceDirectories( getTestSourceDirectories() > ).setConfigLocation( configLocation ) > .setConfigurationArtifacts( collectArtifacts( "config" ) ) > .setPropertyExpansion( propertyExpansion ) > .setHeaderLocation( headerLocation ).setLicenseArtifacts( > collectArtifacts( "license" ) ) > .setCacheFile( cacheFile ).setSuppressionsFileExpression( > suppressionsFileExpression ) > .setEncoding( encoding ).setPropertiesLocation( > propertiesLocation ); > checkstyleExecutor.executeCheckstyle( request ); > {code} > There is a _licence_ hint parameter passed to dependency initializer, but it > is actually not used. Leaving all dependencies being uses as the license one. > * _DefaultCheckstyleExecutor_ adds the dependencies to jar search path > without checking the dependency type. I think dependencies should be checked > for the jar type: > {code:java|title=DefaultCheckstyleExecutor.java:836} > // MCHECKSTYLE-225: load licenses from additional artifacts, not from > classpath > if ( additionalArtifacts != null ) > { > for ( Artifact licenseArtifact : additionalArtifacts ) > { > try > { > resourceManager.addSearchPath( "jar", "jar:" + > licenseArtifact.getFile().toURI().toURL() ); > } > catch ( MalformedURLException e ) > { > // noop > } > } > } > {code} > * Later Plexus _JarResourceLoader_ fails to load the resource from those non > jar dependencies: > {code:java:title=JarHolder.java:62} > public void init() > { > try > { > URL url = new URL( urlpath ); > conn = (JarURLConnection) url.openConnection(); > conn.setAllowUserInteraction( false ); > conn.setDoInput( true ); > conn.setDoOutput( false ); > conn.connect(); > theJar = conn.getJarFile(); > } > catch ( IOException ioe ) > { > } > } > {code} > _init()_ silently suppresses _IOException_ thrown on _connect()_ leaving > _theJar_ as null which causes NPE later referencing _theJar_'s methods. > Definitely another bug, but seems won't be fixed at all since > _plexus-resources_ is abandoned. -- This message was sent by Atlassian JIRA (v6.1.6#6162)