March 23rd, 2010 by Lincoln Baxter III

Using Embedded Glassfish with Maven

Three steps to add Embedded GlassFish to any existing project POM. The Embedded Glassfish project is hosted on, and as it is described, is very simple: “This project develops APIs and tools around “embedded GlassFish v3″. Embedded GFv3 is a delivery vehicle of GFv3 so that applications and tools can use GFv3 just as a library, inside their JVM, instead of having GFv3 as the overload of the entire JVM process. (And no, embedded GFv3 is not meant to be run on JavaME.)”

1. You’ll need to add this plugin repository to your POM:


2. Then add the following plugin to your POM:


3. Commands

  • embedded-glasfish:run – starts the embedded server if it is not already running and deploys the specfied application. The goal keeps the server running, so the user can make changes in the application, reploy and test iteratively.
  • embedded-glassfish:start – starts the embedded server with the specified parameters
  • embedded-glassfish:deploy – deploys the specified application
  • embedded-glassfish:undeploy – undeploys the application identified by the “name” parameter. If no name is specifed all applications are undeployed.
  • embedded-glassfish:stop – stops the embedded server
  • embedded-glassfish:admin – executes the specified admin command on the embedded server. For example, you could create a jdbc resource.


Posted in Java, OpenSource


  1. Looks simple enough for sure! So how can I run unit tests against this embedded glassfish? Or is that where Arquillian comes in?

  2. Lincoln says:

    That’s where Arquillian comes in 🙂

    Arquillian Examples:

  3. Gene De Lisa says:

    Glad I got you started on a new post.

    This works ok but here’s a few observations.

    It requires a war, so you have to say
    mvn package embedded-glassfish:run
    I see that the config element has as a child. Would this be the way to run exploded?

    The only way I can tell how to set up a datasource is like this in the config element.


    Is there an easier way?

    To run Selenium during integration tests you have to do a bit more with the executions. Like this (for just the gf part. you have to add similar executions for Selenium):









    And finally this should be in a profile; especially since you’re about to do a JBoss one right?

    It would be nice if this plugin were better documented.

    1. Gene De Lisa says:

      your blog eats XML – as you can tell by the executions.

      The config child I meant was
      instanceRoot in regard to running exploded

      1. Lincoln says:

        Actually you can also wrap the text in

        <pre>code here<//pre>

        (just one closing /, had to prevent the nested pre tag from being stripped 😉

      2. Lincoln says:

        If you re-post your comment in a ‘pre’ tag, I’ll fix this one.

  4. Lincoln says:

    Yeah, you have to URLencode it. Sorry. I should really add a warning. I don’t really have too much insight on embedded glassfish, since I mostly use JBoss AS6 right now.

    I just went, found a blog, got it working, and posted it.

  5. admin says:


    public class Test {
  6. Alberto Gori says:

    I know that you are the main developer of the Seam faces module.
    Could you explain how to setup a good integration test for JSF using Arquillian?

    For example, I’d like to test what happen when the client requests “/home.jsf?id=3”.
    For what you know, is actually possible?

  7. Stas says:


    I couldn’t get work JSPs hot-swapping. What are the main points to take into consideration?

    Here is my configuration

  8. War file not generated says:

    Configured as stated in your post but when executing "mvn -e clean install" then maven throws a LifecycleExecutionException with caused by: test.war. Looking on the file system the war-file "test.war" wasn’t even created. If I change to version 3.1 then no exception is thrown but
    > PlainTextActionReporterFAILUREFile not found : /Users/grudom/Daten/IDE/EclipseProjects/workspace/transact/test.war06.09.2012 09:18:03 PluginUtil doDeploy
    > INFO: Deployed null
    Why is no war file being generated?

Leave a Comment

Please note: In order to submit code or special characters, wrap it in

[code lang="xml"][/code]
(for your language) - or your tags will be eaten.

Please note: Comment moderation is enabled and may delay your comment from appearing. There is no need to resubmit your comment.