By Fabio Turizo of Payara

Payara Micro allows running web applications in a self-contained and easy way. Since the release of Payara Server 162, 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!

Implementation

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-4.1.1.162.jar --deploy test-app.war --outputUberJar test-app.jar

You will get an output like the following:

Jun 15, 2016 12:04:53 PM fish.payara.micro.PayaraMicro packageUberJar
INFO: Building Uber Jar... test-app.jar
Jun 15, 2016 12:05:09 PM fish.payara.micro.PayaraMicro packageUberJar
INFO: Built Uber Jar test-app.jar in 16036 (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!

Configuration

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-4.1.1.162.jar --deploy test-app.war --outputUberJar test-app.jar --port 9898 --noCluster true
java -jar payara-micro-4.1.1.162.jar --deploy test-app-1.war --deploy test-app-2.war --outputUberJar test-app.jar
[2016-06-15T14:54:11.259-0500] [Payara Micro 4.1] [INFO] [] [PayaraMicro] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1466020451259] [levelValue: 800] Deployed 2 archives

Creating Uber JAR with Payara Micro

| Java Language| 582 views | 0 Comments
About The Author
-

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>