payara / ecosystem-support

Placeholder repository to handle community requests for the Payara Platform ecosystem tools
4 stars 2 forks source link

Bug Report: payara-micro-maven-plugin ignores context root #35

Closed rlfnb closed 2 years ago

rlfnb commented 3 years ago

Description


deploying a WAR with a context root configured in payara-micro-maven-plugin ignores the context root

Expected Outcome

WAR file should be accessible under the context root being specified in the payara-micro-maven-plugin configuration

{ "Instance Configuration": { "Host": "192.168.100.26", "Http Port(s)": "8080", "Https Port(s)": "", "Instance Name": "Graceful-Nibbler", "Instance Group": "MicroShoal", "Hazelcast Member UUID": "9ad7f22b-6ff8-4fd0-8a50-d8f293bf7040", "Deployed": [ { "Name": "RepCaseRedundantDeploy-1.0-SNAPSHOT", "Type": "war", "Context Root": "/" } ] } }

Current Outcome

The the context root is being derived from the WAR name and the specified context root for tart deployment is ignored

{ "Instance Configuration": { "Host": "192.168.100.26", "Http Port(s)": "8080", "Https Port(s)": "", "Instance Name": "Graceful-Nibbler", "Instance Group": "MicroShoal", "Hazelcast Member UUID": "9ad7f22b-6ff8-4fd0-8a50-d8f293bf7040", "Deployed": [ { "Name": "RepCaseRedundantDeploy-1.0-SNAPSHOT", "Type": "war", "Context Root": "/RepCaseRedundantDeploy-1.0-SNAPSHOT" } ] } }

Steps to reproduce

Simply use my PoC attached, unzip it, change into the unzipped dir and type in RepCaseRedundantDeploy.zip

mvn clean install payara-micro:bundle

Environment

OndroMih commented 3 years ago

Hi @rlfnb,

What you're doing in the example project isn't supported. The contextRoot option is only supported by the start goal of the maven plugin, not by the bundle goal.

But there's a better way to do what you're doing which works. You can just replace the following configuration in your project:

                <configuration>
                    <payaraVersion>5.2021.6</payaraVersion>
                    <contextRoot>/</contextRoot>
                    <autoDeployEmptyContextRoot>true</autoDeployEmptyContextRoot>
                    <deployArtifacts>
                        <artifactItem>
                            <groupId>com.fail</groupId>
                            <artifactId>RepCaseRedundantDeploy</artifactId>
                            <version>1.0-SNAPSHOT</version>
                            <type>war</type>
                        </artifactItem>
                    </deployArtifacts>
                </configuration>

With the following configuration:

                <configuration>
                    <payaraVersion>5.2021.6</payaraVersion>
                    <autoDeployEmptyContextRoot>true</autoDeployEmptyContextRoot>
                </configuration>

That's it. However, beware that due to a bug reported in https://github.com/payara/Payara/issues/5363, when you execute the bundle, it won't start, if you use Payara Micro version 5.2021.5 or 5.2021.6. This is going to be fixed in the version 5.2021.7.

The above works because the bundle goal already adds the artifact produced by your maven project into the final bundle automatically, unless you specify <autoDeployArtifact>false</autoDeployArtifact>. No need to refer to the artifact using maven coordinates. And you can specify the context root of that deployment with the <autoDeployContextRoot> option, or with the <autoDeployEmptyContextRoot> option if you want to deploy it to the "empty" context root /.