DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Java EE 6 Pet Catalog with GlassFish and MySQL
  • A Systematic Approach for Java Software Upgrades
  • How Java Apps Litter Beyond the Heap
  • Migrating Spring Java Applications to Azure App Service (Part 1: DataSources and Credentials)

Trending

  • The Twelve-Factor Agents: Building Production-Ready LLM Applications
  • Introducing senro: A Pipeline Engine You Program in Go
  • A Walk-Through of the DZone Article Editor
  • Going All In On the JVM 25 Virtual Threads

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Java
  4. Dockerized Java EE 8 Apps With Glassfish 5.0

Dockerized Java EE 8 Apps With Glassfish 5.0

There's a shiny new base GlassFish Docker image specifically made for Java EE 8 app development. Take a look at what it offers and how you can put it to use.

By 
Sebastian Daschner
·
Oct. 27, 17 · News
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
15.5K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in
GlassFish 5.0 represents the reference implementation of Java EE 8. We can Dockerize Java EE 8 applications by using a GlassFish base image, such as the official oracle/glassfish.

The Dockerfile of a zero-dependency Java EE 8 application looks like as follows:

FROM oracle/glassfish:5.0

COPY target/application.war $GLASSFISH_HOME/glassfish/domains/domain1/autodeploy/


A Docker container of that image starts the application server and auto-deploys our application.

application.war is a thin WAR deployment artifact — what speeds up build, publishing and deployment times. The WAR file comprises only application-specific classes — no implementation-specific JAR files. If needed, any dependencies are added on top of the base image — before the actual application.

Imagine, we want to add the Prometheus Java API:

FROM oracle/glassfish:5.0

ENV GLASSFISH_LIB=$GLASSFISH_HOME/glassfish/domains/domain1/lib/ext/

# add Prometheus Java API
COPY .../simpleclient-0.0.26.jar $GLASSFISH_LIB
COPY .../simpleclient_common-0.0.26.jar $GLASSFISH_LIB

COPY target/application.war $GLASSFISH_HOME/glassfish/domains/domain1/autodeploy/


The application can already use Java EE 8 standards such as JSON-B. The provided dependency is javax:javaee-api:8.0 — same as the Java EE 7 API with an incremented version number.

To see a full example that uses Prometheus, please see Prometheus with Java EE. That example can also run on Java EE 8 and GlassFish 5 by updating the API version to 8.0 and the Docker base image to oracle/glassfish.

Have fun developing Java EE 8 applications for Docker!

Java EE Java (programming language) GlassFish application app

Published at DZone with permission of Sebastian Daschner. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Java EE 6 Pet Catalog with GlassFish and MySQL
  • A Systematic Approach for Java Software Upgrades
  • How Java Apps Litter Beyond the Heap
  • Migrating Spring Java Applications to Azure App Service (Part 1: DataSources and Credentials)

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook