DZone
Java Zone
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
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > 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.

Sebastian Daschner user avatar by
Sebastian Daschner
·
Oct. 27, 17 · Java Zone · News
Like (5)
Save
Tweet
14.14K Views

Join the DZone community and get the full member experience.

Join For Free
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.

Popular on DZone

  • Java Hashtable, HashMap, ConcurrentHashMap: Performance Impact
  • Password Authentication: How to Correctly Do It
  • Don't Underestimate Documentation
  • DZone's Article Submission Guidelines

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo