Payara Micro 5によるUber JARの作成

Uncategorized

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.

Related Posts

Blue background with coral and fish. Left text: 'MONTHLY CATCH'. Right: laptop screen with tech tabs and Payara Community logo. 3 minutes
Community

The Payara Monthly Catch -September 2025

Welcome aboard the September issue of The Monthly Catch! With summer holidays wrapping up, the Java world is back […]

4 minutes
Uncategorized

Leading the Way: Payara Platform Community 7 Beta Now Fully Jakarta EE 11 Certified

We’re excited to announce that Payara Platform Community 7 Beta application server is now fully certified as Jakarta EE 11 […]

Understanding the Security Issues of Aging Middleware 6 minutes
Community

Boost Developer Productivity with Payara Server Maven Plugin + AI Agent

Managing Payara Server Just Got Smarter  Imagine managing your Jakarta EE applications not just with Maven goals, but by […]