Creating Uber JAR with Payara Micro 5

Photo of Fabio Turizo by Fabio Turizo

Payara Micro allows running web applications in a self-contained and easy way. Since the release of Payara Server, there is a simple way to generate an “Uber” JAR that bundles the contents of a WAR file and the classes and resources that compose Payara Micro!



First, generate a web application to be run in Payara Server using traditional means (like Maven for example). Then, deploy this application with Payara Micro with the --outputUberJar option enabled to generate the resulting JAR file:

java -jar payara-micro- --deploy test-app.war --outputUberJar test-app.jar

You will get an output like the following:

Mar 26, 2020 9:51:55 PM fish.payara.micro.PayaraMicro packageUberJar
INFO: Building Uber Jar... test-app.jar
Mar 26, 2020 9:51:55 PM fish.payara.micro.PayaraMicro packageUberJar
INFO: Built Uber Jar test-app.jar in 183 (ms)


And finally, with this Uber jar created, you can just run the application using a simple Java command:


java -jar test-app.jar


With this, the Payara Micro instance will startup and deploy the original web application!  


Now, what happens if you want to change the HTTP port this application uses (8080 by default)? Or disable the clustering capabilities? You can pass all compatible Payara Micro configuration options for the Uber jar generation, and when the application is run these options will be used to configure the server instance:

java -jar payara-micro-5.201.jar --deploy test-app.war --outputUberJar test-app.jar --port 9898 --noCluster


java -jar payara-micro-5.201.jar --deploy test-app-1.war --deploy test-app-2.war --outputUberJar test-app.jar


[2020-03-26T09:56:53.923+0000] [] [INFO] [] [PayaraMicro] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1585303013923] [levelValue: 800] Deployed 2 archive(s)