Using Payara Embedded & Payara Micro with Maven

Uncategorized

At long last, Payara Embedded and Payara Micro are on Maven Central, allowing you to set them as dependencies and use them in your projects. In this blog I’ll briefly cover how to do this.I assume if you’re reading this you already have a Maven project set up, so I’ll start from there. If you haven’t, then just create a new Maven Java project in your favourite IDE.
First off, open the POM.xml file of the module or project that needs to use Payara Embedded or Micro, and add one of the embedded distributions as a dependency:

Payara Embedded All

<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-embedded-all</artifactId>
<version>5.201</version>
<type>jar</type>
</dependency>

Payara Embedded Web

<dependency>
    <groupId>fish.payara.extras</groupId>
    <artifactId>payara-embedded-web</artifactId>
    <version>5.201</version>
    <type>jar</type>
</dependency>

Payara Micro

<dependency>
    <groupId>fish.payara.extras</groupId>
    <artifactId>payara-micro</artifactId>
    <version>5.201</version>
    <type>jar</type>
</dependency>

 And that’s about it! With one of the above added as a dependency, you can now begin using Payara embedded in your application and project. For example, the following code will create and start an embedded Payara server, with the HTTP and HTTPS listener set to ports 8083 and 8184 respectively:

import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.embeddable.BootstrapProperties;
import org.glassfish.embeddable.GlassFishRuntime;
import org.glassfish.embeddable.GlassFish;
import org.glassfish.embeddable.GlassFishException;
import org.glassfish.embeddable.GlassFishProperties;

/**
 * Basic Example showing how to programmatically create, edit, and
 * start an embedded Payara Server.
 * 
 * @author Andrew Pielage
 */
public class EmbeddedExample 
{
    public static void main(String [] args)
    {
        try 
        {
            BootstrapProperties bootstrap = new BootstrapProperties();
            GlassFishRuntime runtime = GlassFishRuntime.bootstrap(bootstrap);
            GlassFishProperties glassfishProperties = new GlassFishProperties();
            glassfishProperties.setPort("http-listener", 8083);
            glassfishProperties.setPort("https-listener", 8184);
            GlassFish glassfish = runtime.newGlassFish(glassfishProperties);
            glassfish.start();
        }
        
        catch (GlassFishException ex) 
        {
            Logger.getLogger(EmbeddedExample.class.getName()).log(Level.SEVERE, 
                    null, ex);
        }
    }
}

Note: You won’t be able to drop in Payara Micro quite like this; Payara Micro is based on the GlassFish Web distribution, and using it programmatically works a little differently (See Steve’s introductory blog for an example).

That’s it for now, if you need further help with using Payara Embedded, you can find the GlassFish guide for using the embedded server here: http://docs.oracle.com/cd/E26576_01/doc.312/e24932/embedded-server-guide.htm#GSESG00001

If you are needing some help with the new Payara Micro, don’t worry, we should have some documentation for it up on our GitHub wiki soon; we’ll let you know when. As always, let us know if there’s any killer feature, improvement, or fix that you want to make it into Payara.

 

 

Comments (5)

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.

  1. Robert Rohm

    Great! It’s really pretty easy and works out of the box!

    What about the web administration console – the console log from the embedded server says, is should be accessible unter /admin, but the server answers with a 404 on http://localhost:8083/admin.
    A I missing something?

  2. Andrew Pielage

    Hi Robert,

    The log is a bit deceptive here – this is merely the context root of the admin console adapter, not the actual admin console. Embedded Payara Server and Payara Micro don’t come bundled with the administration console.

    Thanks,
    Andrew

  3. Gustavo Massaneiro

    I had to switch between Payara Micro to Payara Embedded because Payara Micro was taking about 4-5 minutes to startup on a embedded Debian, using the Payara Embedded-web now it takes about 30 seconds to startup. However I’m able to debug the application normally, but when I generate the war and jar files to run directly on the board I get a glassfish exception:

    java.lang.ClassNotFoundException: org.glassfish.embeddable.GlassFishException

    It seems that the generated jar is missing some glassfish dependency, but debugging it on Eclipse it Works fine. I’m using Java 8. Any ideas?

  4. Markus Karg

    Note that since Payara 4.1.1.171 the following dependency is needed in addition:

    fish.payara.api
    payara-api
    4.1.1.171
    provided

  5. Andrew Gr

    Thank you for the post!

    Quick question: how to access CLI via REST on the Embedded Instance?

    Meaning, it is accessible, but POST’ing here: http://localhost:4848/management/domain/stop

    Gives error:
    WARNING: com.sun.enterprise.v3.admin.StopDomainCommand
    java.lang.IllegalArgumentException: subject
    at com.sun.enterprise.admin.util.CommandSecurityChecker.authorize(CommandSecurityChecker.java:172)

    Thank you!

Related Posts

Community_Announcement 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 […]

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

The Payara Monthly Catch – August 2025

Welcome aboard the August 2025 issue of The Payara Monthly Catch! With summer in full swing, things may have felt […]