0

I am starting a war-packaged Java EE project with payara micro from command line:

java -jar payara-micro.jar --deploy target/application.war

Then I am able to start the app with

http://localhost:8080/application

But is there an option to deploy to an empty context root, so that I can start just with

http://localhost:8080

?

Alex Andersen
  • 127
  • 1
  • 1
  • 14

1 Answers1

4

If you rename your application ROOT.war, it will deploy to the root context if you package it as an Uber JAR.

Otherwise, you can add a <context-root>/</context-root> element to your glassfish-web.xml

Mike
  • 4,852
  • 1
  • 29
  • 48
  • When I rename the war to ROOT.war, I have to start on Payara Micro with `http://localhost:8080/ROOT`. Empty context with ROOT.war works on WildFly, but not with `java -jar payara-micro.jar --deploy ROOT.war`. – Alex Andersen Oct 12 '16 at 16:29
  • Are you running the latest version of Payara Micro? This works by assuming the name of the application is the context root and sets it to root if the name of the application is `ROOT.war`. [The code that does it is here.](https://github.com/payara/Payara/blob/631a2bb72fda5c62f372d2884921bf588b09a206/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/PayaraMicro.java#L1557) – Mike Oct 12 '16 at 19:40
  • Your linked code looks right. I am using the latest version 4.1.1.163 with maven. But It does not work. The log outputs: `[2016-10-13T02:19:28.894+0200] [Payara Micro 4.1] [INFO] [AS-WEB-GLUE-00172] [ja vax.enterprise.web] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 14763179688 94] [levelValue: 800] Loading application [ROOT] at [/ROOT]` – Alex Andersen Oct 13 '16 at 00:23
  • Even deploying a ROOT.war to a classic (not micro) Payara 163 Server sets the context root to "/ROOT" but not to "/" – Alex Andersen Oct 13 '16 at 00:51
  • I found a log output saying `[INFO] [] [PayaraMicro] No META-INF/deploy directory`. Looking into [PayaraMicro.java](https://github.com/payara/Payara/blob/631a2bb72fda5c62f372d2884921bf588b09a206/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/PayaraMicro.java#L1534) the result is, that the ROOT.war-Logic will not be executet. I will check if it works when packaging the ROOT.war into an uber jar. – Alex Andersen Oct 13 '16 at 13:41
  • Looks like I was remembering the details wrong - that is a feature of the Uber JAR packaging, and mostly a workaround to the way deployment happens with UberJARs. The way to do this with a separate deployment would be the standard way of editing the `glassfish-web.xml`. I've updated my answer to correct it. – Mike Oct 16 '16 at 17:55