How to use embedded glassfish maven plugin?

You already know how to use embedded glassfish from junit now it’s time to show you how to use the maven plugin to achieve the same.

You can download the full package here.

As always we start off with pom.xml

<project xmlns="" xmlns:xsi=""

Then we place an web.xml in src/main/webapp/WEB-INF

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="" xmlns="" xmlns:web="" xsi:schemaLocation="" id="WebApp_ID" version="2.5">

Infortenatyl for this type of server we again need an domain.xml (use the one here) and copy next to pom.xml file.

Only thing left to do is create an hello.html file in src/main/webapp

    <title>Tutorial: HelloWorld</title>
    <h1>HelloWorld Tutorial</h1>

To start the embedded glassfish server do

mvn package embedded-glassfish:run

If you change something to hello.html while the embedded server is running you need to package and redeploy the application. How to do so, leave the embedded server running. Change something to hello.html. Open another commandline and fire up the following maven comamnd

mvn package

Now go back to your commandline where the embedded server is running and press enter. Your application will be re-deployed.

To test your hello.html brows to http://localhost:8888/server