Payara Micro 5によるUber JARの作成

Cloud & Microservices

Payara Microでは、Webアプリケーションを自己完結型で簡単に実行することができます。20165月のPayara Serverリリースからは、WARファイルの内容とPayara Microを構成するクラスやリソースを束ねる “Uber JAR” を作成する簡単な方法があります。

この “Uber” Jarは、Dockerコンテナ内でアプリケーションを実行するための最良の方法ではないことに注意してください。アプリケーションに小さなコード変更を加えるたびに、バイナリ全体のアップデートが必要になるためです。より良い方法は、Payara Microインスタンスを起動して、インストールが必要なアプリケーションを指定することです。詳細については Payara Micro Docker Image documentation をご覧ください。

(最終更新日 2021/04/06)

実装

まず、従来の方法(例えばMavenなど)でWebアプリケーションを生成します。次に、このアプリケーションを –outputUberJar オプションを有効にして Payara Micro へデプロイし、結果のJARファイルを生成します。

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

以下のような出力が得られます。

Apr 06, 2021 9:09:47 AM fish.payara.micro.impl.UberJarCreator buildUberJar
INFO: Building Uber Jar... test-app.jar
Apr 06, 2021 9:09:48 AM fish.payara.micro.impl.UberJarCreator buildUberJar
INFO: Built Uber Jar basic-servlet.jar in 450 (ms)

そして最後に、このUber jarを作成すると、簡単なJavaコマンドでアプリケーションを実行することができます。

java -jar test-app.jar

これにより、Payara Microのインスタンスが起動し、元のWebアプリケーションをデプロイします。

では、このアプリケーションが使用するHTTPポート (デフォルトでは8080) を変更したい場合はどうすればよいのでしょうか。あるいは、クラスタリング機能を無効することはできるのでしょうか。Uber jarの生成には、互換性のあるPayara Microの設定オプションをすべて渡すことができ、アプリケーションの実行時には、これらのオプションがサーバー・インスタンスの設定として使用されます。

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

 

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

 

[2021-04-06T09:56:53.923+0000] [] [INFO] [] [PayaraMicro] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1617693676410] [levelValue: 800] Deployed 2 archive(s)

Comments (0)

Post a comment

Your email address will not be published. Required fields are marked *

Payara needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, please review our Legal & Privacy Policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Illustration showing the Payara logo and the words “New Release” in large orange and white text, next to a stylized laptop screen displaying the Payara Server admin console with dark blue and orange interface elements. 4 minutes
News

What’s New in the Payara Platform March 2026 Release?

The March 2026 release brings important platform modernization, stability improvements, and comprehensive bug fixes across the Azul Payara Platform […]

SpringBoot Actuator Health for Microprofile Developers 7 minutes
Cloud & Microservices

Spring Boot Actuator Health for MicroProfile Developers

If you worked with MicroProfile Health, you already understand the value of exposing application health information through standardized endpoints. […]

Webinar banner for “High-Frequency Trading on Jakarta EE: GC Stress Testing with Azul C4 and Payara Micro,” March 25, 2026, 2 PM GMT. Features Azul and Payara Micro logos and speaker photos of Luqman Saeed, Jakarta EE Specialist, and Simon Ritter, Deputy CTO and Java Champion. 1 minute
Cloud & Microservices

High-Frequency Trading on Jakarta EE: Join Our Upcoming Live Webinar

Modern high-frequency trading (HFT) platforms operate under extreme performance constraints, processing tens of thousands of messages per second while […]