[ https://jira.codehaus.org/browse/MCHECKSTYLE-231?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=347798#comment-347798 ]
Dennis Lundberg commented on MCHECKSTYLE-231: --------------------------------------------- Hi Marcus, The way you are referencing the Checkstyle configuration files in build-tools is not the correct way to do it. When using Maven you should never directly try to access files outside of a project's directory. Please follow the instructions here: http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html I'm not 100% sure that this is the the reason for your NPE, but you should try this first. If you need to run 'mvn install' to make a build work and 'mvn verify' doesn't work, it is usually a sign that you are somehow violating the Maven principle that each project/artifact should be self contained and all the necessary resources should be available on the classpath (through some dependency mechanism). > NPE on mvn compile > ------------------ > > Key: MCHECKSTYLE-231 > URL: https://jira.codehaus.org/browse/MCHECKSTYLE-231 > Project: Maven Checkstyle Plugin > Issue Type: Bug > Affects Versions: 2.12.1 > Environment: Apache Maven 3.2.1 > (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00) > Maven home: /usr/local/Cellar/maven/3.2.1/libexec > Java version: 1.7.0_51, vendor: Oracle Corporation > Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre > Default locale: en_US, platform encoding: UTF-8 > OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac" > checkstyle plugin version: 2.12.1 > Reporter: Marcus Höjvall > Priority: Critical > > I'm getting a NullPointerError when running: > {code} mvn clean compile -Pall {code} > And all is a profile running the checkstyle plugin. This however works if I > run install instead of compile, like this: > {code} mvn clean install -Pall {code} > Compile however works good when running it on a submodule but not on the root > module. > I don't know how to proceed and maven told me to contact the plugin > maintainers through this link: > https://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException > Please let me know if there is anymore information that I need to provide or > other ways to help out > Stacktrace: > {code} > [ERROR] Failed to execute goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.12.1:checkstyle (validate) > on project izettle-ejb: Execution validate of goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.12.1:checkstyle failed. > NullPointerException -> [Help 1] > org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute > goal org.apache.maven.plugins:maven-checkstyle-plugin:2.12.1:checkstyle > (validate) on project izettle-ejb: Execution validate of goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.12.1:checkstyle 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:108) > at > org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) > at > org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) > at > org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) > 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:213) > at org.apache.maven.cli.MavenCli.main(MavenCli.java:157) > 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 > validate of goal > org.apache.maven.plugins:maven-checkstyle-plugin:2.12.1:checkstyle failed. > at > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:144) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) > ... 19 more > Caused by: java.lang.NullPointerException > 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:70) > at > org.codehaus.plexus.resource.DefaultResourceManager.getResourceAsFile(DefaultResourceManager.java:91) > at > org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.getOverridingProperties(DefaultCheckstyleExecutor.java:460) > at > org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.getConfiguration(DefaultCheckstyleExecutor.java:299) > at > org.apache.maven.plugin.checkstyle.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:185) > at > org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:488) > at > org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:156) > at > org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:196) > at > org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:104) > at > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133) > ... 20 more > {code} > Root pom > {code:xml} > <plugin> > <artifactId>maven-checkstyle-plugin</artifactId> > <version>2.12.1</version> > <dependencies> > <dependency> > <groupId>com.company</groupId> > <artifactId>build-tools</artifactId> > <version>1.0</version> > </dependency> > </dependencies> > <executions> > <execution> > <id>validate</id> > <phase>install</phase> > <goals> > <goal>checkstyle</goal> > </goals> > <configuration> > > <includeTestSourceDirectory>false</includeTestSourceDirectory> > <failsOnError>true</failsOnError> > <consoleOutput>true</consoleOutput> > > <configLocation>${project.parent.basedir}/company-build-tools/src/main/resources/checkstyle/checkstyle.xml</configLocation> > <linkXRef>false</linkXRef> > > <propertyExpansion>checkstyle-suppression-file=${project.basedir}/checkstyle-suppression.xml</propertyExpansion> > </configuration> > </execution> > </executions> > </plugin> > {code} > {code:xml} > <profile> > <id>all</id> > <build> > <plugins> > <plugin> > <artifactId>maven-checkstyle-plugin</artifactId> > <executions> > <execution> > <configuration> > > <propertyExpansion>projectDir=${project.basedir </propertyExpansion> > </configuration> > <id>validate</id> > <goals> > <goal>checkstyle</goal> > </goals> > </execution> > </executions> > </plugin> > </plugins> > </build> > </profile> > {code} -- This message was sent by Atlassian JIRA (v6.1.6#6162)