
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 […]
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.
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:
<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-embedded-all</artifactId>
<version>5.201</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-embedded-web</artifactId>
<version>5.201</version>
<type>jar</type>
</dependency>
<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.
Share:
We’re excited to announce that Payara Platform Community 7 Beta application server is now fully certified as Jakarta EE 11 […]
Managing Payara Server Just Got Smarter Imagine managing your Jakarta EE applications not just with Maven goals, but by […]
Welcome aboard the August 2025 issue of The Payara Monthly Catch! With summer in full swing, things may have felt […]
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?
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
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?
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
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!