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.

Related Posts

payara qube logo 5 minutes
Payara

Payara Cloud Is Now part of Payara Qube family of Unified Platforms for Enterprise Java

Payara Cloud is becoming part of Payara Qube family of Java application deployment runtimes. This move reflects how the […]

Payara promotional graphic showing transition from Spring to Jakarta EE, including technology logos, a code icon and arrows leading from Spring to Jakarta EE. 6 minutes
Jakarta EE

From Spring Boot To Jakarta EE 11: How Payara Starter Eases The Transition

If you’ve been living in the Spring ecosystem, you’re used to fast project setup. Spring Initializr gives you a […]

Promotional graphic for a podcast episode titled “Why Open Source is the Future of Business Innovation - A conversation with Arun Gupta”. The podcast is hosted by Payara Community. The right side features a photo of the speaker, Arun Gupta, labeled as a “VP, Developer Experience at JetBrains”. The design uses dark blue and teal backgrounds with coral and fish illustrations. 2 minutes
Community

Payara Podcast – Why Open Source is the Future of Business Innovation – A Conversation with Arun Gupta

Open source is no longer a developer-only concern — it’s at the heart of how modern businesses innovate, build […]