0

I have a Java EE application (with maven) which currently is packaged into a .war file. What I want to do now is execute this project with a Payara Micro Embedded server. This is done like this:

public static void main(String[] args) {
    PayaraMicro.getInstance().addDeployment("test.war").bootStrap();
}

The complete application should be packaged into a .jar file and fire up the application server and deploy the application automatically. How do I achieve this?

Simon Schiller
  • 644
  • 1
  • 8
  • 23
  • 3
    Googling "payara micro embedded build jar" Resulted in this nice blog post: http://blog.payara.fish/creating-uber-jar-with-payara-micro – Gimby Jan 31 '17 at 12:28

1 Answers1

1

With Payara Micro, you don't have to write any additional code to run your WAR application or package it is an executable JAR file together with all the dependencies.

Just to run the application (in development or tests), you can do:

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

If you need to package everything as a single JAR, do the following after your WAR application is built in order to create myapplication-standalone.jar, which you can run with java -jar later:

java -jar payara-micro.jar --deploy target/myapplication.war --outputUberJar target/myapplication-standalone.jar

You can now execute your application deployed in payara micro with this command:

java -jar target/myapplication-standalone.jar

The latter approach is described in more detail in Payara blog, including how to integrate it with your maven build. You can find further documentation about this feature of Payara Micro in the documentation.

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
OndroMih
  • 7,280
  • 1
  • 26
  • 44
  • I think that Simon wanted to do a project with embeded payara not to deploy the application to the standalone payara(micro) server. – Jouffan Sep 07 '21 at 15:25