NPE using maven plugin

67 views
Skip to first unread message

ken gengler

unread,
Aug 10, 2018, 7:38:58 PM8/10/18
to Payara Forum
I'm trying to use the maven micro plugin to build an uber jar. But I'm always ending up with a failed build due to an NPE. I've started with an application generated by the archetype:
  mvn archetype:generate -DarchetypeGroupId=fish.payara.maven.archetypes -DarchetypeArtifactId=payara-micro-maven-archetype -DarchetypeVersion=1.0.1 -DgroupId=fish.payara.micro -DartifactId=micro-sample -Dversion=1.0-SNAPSHOT -Dpackage=fish.payara.micro.sample -Darchetype.interactive=false
Then I perform a 
  mvn install
to place the WAR in my local maven repo.
And, next I try to build the uber jar with
 mvn payara-micro:bundle
Which works up to a point:

[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< fish.payara.micro:micro-sample >-------------------
[INFO] Building micro-sample 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- payara-micro-maven-plugin:1.0.1:bundle (default-cli) @ micro-sample ---
[INFO] Configured Artifact: fish.payara.extras:payara-micro:5.182:jar
[INFO] Unpacking /Users/gengler/Documents/.m2/repository/fish/payara/extras/payara-micro/5.182/payara-micro-5.182.jar to /Users/gengler/Work/git/micro-sample/target/extracted-payaramicro with includes "" and excludes ""
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/gengler/Work/git/micro-sample/src/main/resources
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/gengler/Work/git/micro-sample/src/main/resources
[INFO] Configured Artifact: fish.payara.micro:micro-sample:1.0-SNAPSHOT:war
[INFO] Copying micro-sample-1.0-SNAPSHOT.war to /Users/gengler/Work/git/micro-sample/target/extracted-payaramicro/MICRO-INF/deploy/ROOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.494 s
[INFO] Finished at: 2018-08-10T16:34:30-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal fish.payara.maven.plugins:payara-micro-maven-plugin:1.0.1:bundle (default-cli) on project micro-sample: Execution default-cli of goal fish.payara.maven.plugins:payara-micro-maven-plugin:1.0.1:bundle failed.: NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:

If I run maven with debug and exception info logged, I see that the NPE at:
Caused by: java.lang.NullPointerException
    at fish.payara.maven.plugins.micro.processor.ArtifactDeployProcessor.handle (ArtifactDeployProcessor.java:103)
    at fish.payara.maven.plugins.micro.processor.BaseProcessor.gotoNext (BaseProcessor.java:77)

I think its trying to get the file from the artifact. I've also followed the blog post and tried to explicitly deploy the WAR, but that didn't get me any further.

I'm sure this works and I'm just missing something stupid. But if someone could point it out to me, I'd really appreciate it.

Ken
micro-profile-bundle-exc.txt

Ondro Mihályi

unread,
Aug 11, 2018, 3:08:51 AM8/11/18
to Payara Forum
Hi,

This is a bug in 1.0.1 version of Maven plugin. Please report this as a bug in https://github.com/payara/ecosystem-maven/issues.

If you change version of maven plugin to 1.0.0 the bundle goal works.

You can alternatively use the start goal to create an uber JAR with the --outputuberjar option with the following config in pom.xml:

                        <configuration>
                            <commandLineOptions>
                                <option>
                                    <key>--autobindhttp</key>
                                </option>
                                <option>
                                    <key>--deploy</key>
                                    <value>${project.build.directory}/${project.build.finalName}.war</value>
                                </option>
                                <option>
                                    <key>--outputuberjar</key>
                                    <value>${project.build.directory}/${project.build.finalName}-bundle.jar</value>
                                </option>
                            </commandLineOptions>
                        </configuration>


Ondro

Ondro Mihályi

unread,
Aug 11, 2018, 6:57:53 AM8/11/18
to Payara Forum
Hi,

Even simpler solution is to run the bundle goal within the install command so that they are all executed in a single maven build:

mvn install payara-micro:bundle

This works also in the current 1.0.1 version of the plugin.

I hope it helps,
Ondro
Message has been deleted

ken gengler

unread,
Aug 11, 2018, 12:13:05 PM8/11/18
to Payara Forum
I never would have thought that putting them together in a single maven run would make a difference. Live and learn... Thank you!

Ondro Mihályi

unread,
Aug 11, 2018, 12:46:38 PM8/11/18
to ken gengler, Payara Forum
That's the life with Maven, which doesn't allow to specify dependencies between plugin goals.

I've created a fix to avoid the exception but it's more like a workaround than a proper solution. It's still best to run the WAR plugin before the bundle goal.

Ondro

Dňa so 11. 8. 2018, 18:12 ken gengler <kgen...@gmail.com> napísal(a):
I never would have thought that putting them together in a single maven run would make a difference. Live and learn... Thank you!

--
You received this message because you are subscribed to the Google Groups "Payara Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to payara-forum...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/payara-forum/024210ee-8581-42aa-85bf-39fa6baeb78c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages