Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointer during generate-module-info #91

Open
feldmann65 opened this issue Jan 16, 2019 · 10 comments
Open

NullPointer during generate-module-info #91

feldmann65 opened this issue Jan 16, 2019 · 10 comments

Comments

@feldmann65
Copy link

feldmann65 commented Jan 16, 2019

I'm getting an NullPointerException when generating module-info.java:

[ERROR] Failed to execute goal org.moditect:moditect-maven-plugin:1.0.0.Beta2:generate-module-info (default-cli) on project build-compiler: Execution default-cli of goal org.moditect:moditect-maven-plugin:1.0.0.Beta2:generate-module-info failed.: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.moditect:moditect-maven-plugin:1.0.0.Beta2:generate-module-info (default-cli) on project build-compiler: Execution default-cli of goal org.moditect:moditect-maven-plugin:1.0.0.Beta2:generate-module-info failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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.moditect:moditect-maven-plugin:1.0.0.Beta2:generate-module-info failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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: java.lang.NullPointerException
    at org.moditect.mavenplugin.generate.GenerateModuleInfoMojo.getAssignedModuleNamesByModule (GenerateModuleInfoMojo.java:131)
    at org.moditect.mavenplugin.generate.GenerateModuleInfoMojo.execute (GenerateModuleInfoMojo.java:103)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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)

The Maven config is like this:
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Beta2</version>
<executions>
<execution>
<id>generate-module-info</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-module-info</goal>
</goals>
<configuration>
<modules>
<module>
<artifact>
<groupId>de.spinoza.bla</groupId>
<artifactId>blabla</artifactId>
<version>3.10.1-SNAPSHOT</version>
</artifact>
<moduleInfo>
<name>de.spinoza.bla.blabla</name>
</moduleInfo>
</module>
</modules>
</configuration>
</execution>
</executions>
</plugin>

@lestephane
Copy link

I'll submit a PR which might help you go further. But I still am unable despite my fix to get the command to work on a reactor build project, where the parent POM defines a ${version} property, and where the maven module uses the ${version} property in its 's .

@lingocoder
Copy link

…and where the maven module uses the ${version} property in its 's …

@lestephane? What is „its 's“ a typo of?

@lingocoder
Copy link

lingocoder commented Sep 16, 2020

As reported in Stack Overflow, this same NPE — exact same stack trace — happens when this plugin is applied to try to resolve this other project's issue.

This is the moditect-maven-plugin setup that causes the NPE in that project…

…
 <plugin>
    <groupId>org.moditect</groupId>
    <artifactId>moditect-maven-plugin</artifactId>
    <version>1.0.0.RC1</version>
    <executions>
        <execution>
            <id>generate-module-info</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate-module-info</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/modules</outputDirectory>
                <modules>
                    <module>
                        <artifact>
                            <groupId>org.apache.poi</groupId>
                            <artifactId>poi-ooxml</artifactId>
                            <version>4.1.2</version>
                        </artifact>
                        <moduleInfoSource>
       module poi.ooxml {
           exports org.apache.poi.ooxml;
           exports org.apache.poi.ooxml.dev;
           exports org.apache.poi.ooxml.extractor;
           exports org.apache.poi.ooxml.util;
           exports org.apache.poi.openxml4j.exceptions;
           exports org.apache.poi.openxml4j.opc;
           exports org.apache.poi.openxml4j.opc.internal;
           exports org.apache.poi.openxml4j.opc.internal.marshallers;
           exports org.apache.poi.openxml4j.opc.internal.unmarshallers;
           exports org.apache.poi.openxml4j.util;
           exports org.apache.poi.poifs.crypt.agile;
           exports org.apache.poi.poifs.crypt.dsig;
           exports org.apache.poi.poifs.crypt.dsig.facets;
           exports org.apache.poi.poifs.crypt.dsig.services;
           exports org.apache.poi.poifs.crypt.temp;
           exports org.apache.poi.xddf.usermodel;
           exports org.apache.poi.xddf.usermodel.chart;
           exports org.apache.poi.xddf.usermodel.text;
           exports org.apache.poi.xdgf.exceptions;
           exports org.apache.poi.xdgf.extractor;
           exports org.apache.poi.xdgf.geom;
           exports org.apache.poi.xdgf.usermodel;
           exports org.apache.poi.xdgf.usermodel.section;
           exports org.apache.poi.xdgf.usermodel.section.geometry;
           exports org.apache.poi.xdgf.usermodel.shape;
           exports org.apache.poi.xdgf.usermodel.shape.exceptions;
           exports org.apache.poi.xdgf.util;
           exports org.apache.poi.xdgf.xml;
           exports org.apache.poi.xslf.draw;
           exports org.apache.poi.xslf.extractor;
           exports org.apache.poi.xslf.model;
           exports org.apache.poi.xslf.usermodel;
           exports org.apache.poi.xslf.util;
           exports org.apache.poi.xssf;
           exports org.apache.poi.xssf.binary;
           exports org.apache.poi.xssf.eventusermodel;
           exports org.apache.poi.xssf.extractor;
           exports org.apache.poi.xssf.model;
           exports org.apache.poi.xssf.streaming;
           exports org.apache.poi.xssf.usermodel;
           exports org.apache.poi.xssf.usermodel.charts;
           exports org.apache.poi.xssf.usermodel.extensions;
           exports org.apache.poi.xssf.usermodel.helpers;
           exports org.apache.poi.xssf.util;
           exports org.apache.poi.xwpf;
           exports org.apache.poi.xwpf.extractor;
           exports org.apache.poi.xwpf.model;
           exports org.apache.poi.xwpf.usermodel;
       }
                        </moduleInfoSource>
                    </module>
                    <module>
                        <artifact>
                            <groupId>org.jasypt</groupId>
                            <artifactId>jasypt</artifactId>
                            <version>1.9.3</version>
                        </artifact>
                        <moduleInfo>
                            <name>jasypt</name>
                        </moduleInfo>
                    </module>
                </modules>
            </configuration>
        </execution>
    </executions>
 </plugin>
…

Even though /project/build/plugins/plugin[N]/executions/execution/configuration/modules is definitely present in the moditect-maven-plugin configuration, for some reason the mojo's List<ModuleConfiguration> modules parameter is inexplicably null whenever GenerateModuleInfoMojo.getAssignedModuleNamesByModule(ArtifactResolutionHelper) goes to loop over modules.

@gunnarmorling
Copy link
Member

A PR for fixing this will be welcomed! FWIW, I don't have much bandwidth for ModiTect these days, so that'd be the best avenue for getting solution. Thanks for your understanding!

@lestephane
Copy link

…and where the maven module uses the ${version} property in its 's …

@lestephane? What is „its 's“ a typo of?

Sorry I don't recall.

@Bensmed
Copy link

Bensmed commented Aug 24, 2022

Same problem!

@artsiom-panko
Copy link

artsiom-panko commented Apr 4, 2023

Hi,
I have the same problem, trying to create module-info for net.java.dev.jna libriary

<plugin> <groupId>org.moditect</groupId> <artifactId>moditect-maven-plugin</artifactId> <version>1.0.0.RC3</version> <executions> <execution> <id>generate-module-info</id> <phase>generate-sources</phase> <goals> <goal>generate-module-info</goal> </goals> <configuration> <modules> <module> <artifact> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> <version>5.12.1</version> </artifact> <moduleInfo> <name>net.java.dev.jna</name> </moduleInfo> </module> </modules> </configuration> </execution> </executions> </plugin>

@bmarwell
Copy link
Contributor

Same problem.

If it helps, I don't get an NPE when using moduleInfoSource, but when I use moduleInfo with name, requires and exports instead, it crashes.

Caused by: java.lang.NullPointerException
    at java.util.Objects.requireNonNull (Objects.java:233)
    at org.apache.maven.project.SnapshotModelCache.<init> (SnapshotModelCache.java:32)
    at org.apache.maven.project.SnapshotModelCacheFactory.createCache (SnapshotModelCacheFactory.java:57)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:266)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:172)
    at org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate.collectDependencies (DependencyCollectorDelegate.java:179)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:87)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies (DefaultRepositorySystem.java:305)
    at org.moditect.mavenplugin.util.ArtifactResolutionHelper.getCompilationDependencies (ArtifactResolutionHelper.java:96)
    at org.moditect.mavenplugin.generate.ModuleInfoGenerator.getDependencies (ModuleInfoGenerator.java:169)
    at org.moditect.mavenplugin.generate.ModuleInfoGenerator.generateModuleInfo (ModuleInfoGenerator.java:85)
    at org.moditect.mavenplugin.add.AddModuleInfoMojo.getModuleInfoSource (AddModuleInfoMojo.java:372)
    at org.moditect.mavenplugin.add.AddModuleInfoMojo.execute (AddModuleInfoMojo.java:190)

@bmarwell
Copy link
Contributor

bmarwell commented Feb 7, 2024

@gunnarmorling this is still a problem. Can't promise to look into it. But if someone does, can you review, merge and release it?

Still using the workaround with moduleInfoSource.

bmarwell added a commit to bmarwell/moditect that referenced this issue Feb 8, 2024
Really fixes moditect#228.
This will also show the NPE everyone is talking about in moditect#91.
bmarwell added a commit to bmarwell/moditect that referenced this issue Feb 8, 2024
Really fixes moditect#228.
This will also show the NPE everyone is talking about in moditect#91.
bmarwell added a commit to bmarwell/moditect that referenced this issue Feb 8, 2024
Really fixes moditect#228.
This will also show the NPE everyone is talking about in moditect#91.
bmarwell added a commit to bmarwell/moditect that referenced this issue Feb 8, 2024
Really fixes moditect#228.
This will also show the NPE everyone is talking about in moditect#91.
@bmarwell
Copy link
Contributor

bmarwell commented Feb 9, 2024

As reported in Stack Overflow, this same NPE — exact same stack trace — happens when this plugin is applied to try to resolve this other project's issue.

This is the moditect-maven-plugin setup that causes the NPE in that project…

That is actually not supported... the generate-module-info goal does not take moduleInfoSource as a configuration paramter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants