Payara Micro config - context root

created onJanuary 28, 2022

setting the context root

setting the context root can be done in different ways:

  • context root defined by war file name
  • context root defined by parameter of payara micro start command
  • context root defined by parameter of payara micro start command
  • context root defined by value in glassfish-web.xml

renaming the war file

renaming the war file to changes the context root to

renaming the war file to changes the context root to

command line parameter contextroot

the context root can be set with

java -jar payara-micro.jar --deploy whatever.war --contextroot /

command line parameter deploy

the context root can be included in the argument to the . It follows the path to the war file separated by ( for Linux, for Windows).

general form: , i.e. to deploy with context root , run:

java -jar payara-micro.jar --deploy some.war:/whatever

combinig contextroot and deploy

and can be used together:

java -jar payara-micro.jar --contextroot bar --deploy /home/user/example.war:foo --deploy /home/user/test.war

here is deployed in while is deployed in

is identical to and deploys to the effective context root while deploys to . It follows that leading can be given but aren’t required.

the tailing / must not be given. Using example.war:/foo/ renders the URL <host>/foo/ inaccessible.

glassfish-web.xml

the context root can (obviously) be set in the configuration file , which is located in :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd"> <glassfish-web-app error-url=""> <context-root>/whatever</context-root> </glassfish-web-app>