Initial Contribution

Signed-off-by: Vinay Vishal <vinay.vishal@oracle.com>
diff --git a/appserver/tests/embedded/README b/appserver/tests/embedded/README
new file mode 100644
index 0000000..5ca4b06
--- /dev/null
+++ b/appserver/tests/embedded/README
@@ -0,0 +1,6 @@
+Set the following before running 'mvn clean verify':
+
+MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=384m"
+
+(See http://jira.codehaus.org/browse/MCOMPILER-64)
+
diff --git a/appserver/tests/embedded/basic/README b/appserver/tests/embedded/basic/README
new file mode 100644
index 0000000..9df06a6
--- /dev/null
+++ b/appserver/tests/embedded/basic/README
@@ -0,0 +1,15 @@
+These are the unit tests for testing the APIs provided in org.glassfish.embeddable package.
+
+Mainly these tests require the following artifacts :
+ 
+1.  ~/.m2/repository/org/glassfish/extras/glassfish-embedded-all/3.1-SNAPSHOT/glassfish-embedded-all-3.1-SNAPSHOT.jar
+
+2. ~/.m2/repository/junit/junit/4.3.1/junit-4.3.1.jar
+
+3. ~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.0.2/maven-compiler-plugin-2.0.2.jar
+
+4. ~/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.4.2/maven-surefire-plugin-2.4.2.jar
+
+
+
+
diff --git a/appserver/tests/embedded/basic/lifecycle/README b/appserver/tests/embedded/basic/lifecycle/README
new file mode 100644
index 0000000..9b0dc61
--- /dev/null
+++ b/appserver/tests/embedded/basic/lifecycle/README
@@ -0,0 +1,11 @@
+Tests newGlassFish(), start(), stop(), dispose() lifecyle operations.
+
+1. Two instances of GlassFish are created.
+
+2. On each instance, start(), stop() is called multiple times.
+
+3. Both the instances are disposed.
+
+4. Checks whether the temp dirs are cleaned up or not.
+
+Check the <dependency> and <plugins> sections to check the artifacts used.
diff --git a/appserver/tests/embedded/basic/lifecycle/pom.xml b/appserver/tests/embedded/basic/lifecycle/pom.xml
new file mode 100644
index 0000000..9ef7808
--- /dev/null
+++ b/appserver/tests/embedded/basic/lifecycle/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.basic</groupId>
+    <artifactId>lifecycle</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Test newGlassFish(), start(), stop(), dispose() lifecyle operations</name>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <forkMode>always</forkMode>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>${project.version}</version>
+                </dependency>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>
diff --git a/appserver/tests/embedded/basic/lifecycle/src/test/java/org/glassfish/tests/embedded/basic/lifecycle/LifeCycleTest.java b/appserver/tests/embedded/basic/lifecycle/src/test/java/org/glassfish/tests/embedded/basic/lifecycle/LifeCycleTest.java
new file mode 100644
index 0000000..568241f
--- /dev/null
+++ b/appserver/tests/embedded/basic/lifecycle/src/test/java/org/glassfish/tests/embedded/basic/lifecycle/LifeCycleTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.basic.lifecycle;
+
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishException;
+import org.glassfish.embeddable.GlassFishProperties;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.logging.Logger;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class LifeCycleTest {
+
+    Logger logger = Logger.getAnonymousLogger();
+
+    GlassFishRuntime runtime;
+
+    @Test
+    public void test() throws GlassFishException {
+        runtime = GlassFishRuntime.bootstrap();
+
+        GlassFish instance1 = runtime.newGlassFish();
+        logger.info("Instance1 created" + instance1);
+        instance1.start();
+        logger.info("Instance1 started #1");
+	sleep();
+        instance1.stop();
+        logger.info("Instance1 stopped #1");
+        instance1.start();
+        logger.info("Instance1 started #2");
+	sleep();
+        instance1.stop();
+        logger.info("Instance1 stopped #2");
+        instance1.dispose();
+        logger.info("Instance1 disposed");
+        checkDisposed();
+
+
+        GlassFishProperties props = new GlassFishProperties();
+        props.setProperty("glassfish.embedded.tmpdir", System.getProperty("user.dir"));
+        GlassFish instance2 = runtime.newGlassFish(props);
+        logger.info("instance2 created" + instance2);
+        instance2.start();
+        logger.info("Instance2 started #1");
+	sleep();
+        instance2.stop();
+        logger.info("Instance2 stopped #1");
+        instance2.start();
+        logger.info("Instance2 started #2");
+	sleep();
+        instance2.stop();
+        logger.info("Instance2 stopped #2");
+        instance2.dispose();
+        logger.info("Instance2 disposed");
+        checkDisposed();
+    }
+
+    private void sleep() {
+	try {
+	  Thread.sleep(1000);
+	} catch(Exception ex) {
+	}
+    }
+    // throws exception if the temp dir is not cleaned out.
+
+    private void checkDisposed() {
+        String instanceRoot = System.getProperty("com.sun.aas.instanceRoot");
+        logger.info("Checking whether " + instanceRoot + " is disposed or not");
+        if (new File(instanceRoot).exists()) {
+            throw new RuntimeException("Directory " + instanceRoot +
+                    " is not cleaned up after glassfish.dispose()");
+        }
+    }
+}
diff --git a/appserver/tests/embedded/basic/pom.xml b/appserver/tests/embedded/basic/pom.xml
new file mode 100755
index 0000000..8982068
--- /dev/null
+++ b/appserver/tests/embedded/basic/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>basic</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>Basic tests for testing org.glassfish.embeddable APIs</name>
+    <modules>
+    	<module>lifecycle</module>
+    </modules>
+</project>
diff --git a/appserver/tests/embedded/cdi_basic/pom.xml b/appserver/tests/embedded/cdi_basic/pom.xml
new file mode 100644
index 0000000..7431bdd
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.basic</groupId>
+    <artifactId>cdi_basic</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Basic CDI Test</name>
+    <build>
+        <finalName>cdi_basic</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <forkMode>always</forkMode>
+                    <useSystemClassLoader>false</useSystemClassLoader>
+                    <useManifestOnlyJar>false</useManifestOnlyJar>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>
diff --git a/appserver/tests/embedded/cdi_basic/src/main/config/.gitkeep_empty_dir b/appserver/tests/embedded/cdi_basic/src/main/config/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/config/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/BasicCDITestServlet.java b/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/BasicCDITestServlet.java
new file mode 100644
index 0000000..9edaa12
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/BasicCDITestServlet.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_basic;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+@WebServlet(name = "BasicCDITestServlet",
+        urlPatterns = "/BasicCDITestServlet")
+public class BasicCDITestServlet extends HttpServlet {
+
+    @javax.inject.Inject TestBean tb;
+    @javax.inject.Inject TestRequestScopedBean trsb;
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+        out.println("Hi from BasicCDITestServlet");
+	if(tb == null) {
+	  out.println("TestBean not injected.");
+	} else if(trsb == null) {
+	  out.println("TestRequestScopeBean not injected.");
+	} else {
+	  out.println("TestBean injected. [" + tb + "]");
+	  out.println("TestRequestScopeBean injected. [ " + trsb + "]");
+	  out.println("All CDI beans have been injected.");
+	}
+        out.flush();
+        out.close();
+    }
+}
+
diff --git a/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/TestBean.java b/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/TestBean.java
new file mode 100644
index 0000000..1d819c4
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/TestBean.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_basic;
+
+//Simple TestBean to test CDI. 
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+public class TestBean
+{}
diff --git a/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/TestRequestScopedBean.java b/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/TestRequestScopedBean.java
new file mode 100644
index 0000000..0138242
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/java/org/glassfish/tests/embedded/cdi_basic/TestRequestScopedBean.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_basic;
+
+//Simple RequestScoped TestBean to test CDI. 
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+@javax.enterprise.context.RequestScoped
+public class TestRequestScopedBean
+{}
diff --git a/appserver/tests/embedded/cdi_basic/src/main/resources/.gitkeep_empty_dir b/appserver/tests/embedded/cdi_basic/src/main/resources/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/resources/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/beans.xml b/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/beans.xml
diff --git a/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..67d7bfc
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>/cdi_basic</context-root> 
+</sun-web-app>
diff --git a/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..af71778
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+  <display-name>cdi_basic</display-name>  
+  <distributable/>
+</web-app>
diff --git a/appserver/tests/embedded/cdi_basic/src/main/webapp/images/.gitkeep_empty_dir b/appserver/tests/embedded/cdi_basic/src/main/webapp/images/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/main/webapp/images/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/cdi_basic/src/test/java/org/glassfish/tests/embedded/cdi_basic/BasicCDITest.java b/appserver/tests/embedded/cdi_basic/src/test/java/org/glassfish/tests/embedded/cdi_basic/BasicCDITest.java
new file mode 100644
index 0000000..d0298db
--- /dev/null
+++ b/appserver/tests/embedded/cdi_basic/src/test/java/org/glassfish/tests/embedded/cdi_basic/BasicCDITest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_basic;
+
+import junit.framework.Assert;
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishProperties;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.glassfish.embeddable.archive.ScatteredArchive;
+import org.glassfish.embeddable.archive.ScatteredEnterpriseArchive;
+import org.glassfish.embeddable.web.HttpListener;
+import org.glassfish.embeddable.web.WebContainer;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class BasicCDITest{
+
+    @Test
+    public void test() throws Exception {
+
+        GlassFishProperties props = new GlassFishProperties();
+        props.setPort("http-listener", 8080);
+        GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(props);
+        glassfish.start();
+
+        // Test Scattered Web Archive
+        ScatteredArchive sa = new ScatteredArchive("cdi_basic",
+                ScatteredArchive.Type.WAR, new File("src/main/webapp"));
+        sa.addClassPath(new File("target/classes"));
+        sa.addClassPath(new File("src/main/resources"));
+        URI warURI = sa.toURI();
+        printContents(warURI);
+
+        // Deploy archive
+        Deployer deployer = glassfish.getDeployer();
+        String appname = deployer.deploy(warURI);
+        System.out.println("Deployed [" + appname + "]");
+        Assert.assertEquals(appname, "cdi_basic");
+
+        // Now create a http listener and access the app.
+        WebContainer webcontainer = glassfish.getService(WebContainer.class);
+        HttpListener listener = new HttpListener();
+        listener.setId("my-listener");
+        listener.setPort(9090);
+        webcontainer.addWebListener(listener);
+
+        get("http://localhost:8080/cdi_basic/BasicCDITestServlet",
+                "All CDI beans have been injected.");
+
+        deployer.undeploy(appname);
+
+        glassfish.dispose();
+
+    }
+
+    private void get(String urlStr, String result) throws Exception {
+        URL url = new URL(urlStr);
+        URLConnection yc = url.openConnection();
+        System.out.println("\nURLConnection [" + yc + "] : ");
+        BufferedReader in = new BufferedReader(new InputStreamReader(
+                yc.getInputStream()));
+        String line = null;
+        boolean found = false;
+        while ((line = in.readLine()) != null) {
+            System.out.println(line);
+            if (line.indexOf(result) != -1) {
+                found = true;
+            }
+        }
+        Assert.assertTrue(found);
+        System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+    }
+
+    void printContents(URI jarURI) throws IOException {
+        JarFile jarfile = new JarFile(new File(jarURI));
+        System.out.println("\n\n[" + jarURI + "] contents : \n");
+        Enumeration<JarEntry> entries = jarfile.entries();
+        while (entries.hasMoreElements()) {
+            JarEntry entry = entries.nextElement();
+            System.out.println(entry.getSize() + "\t" + new Date(entry.getTime()) +
+                    "\t" + entry.getName());
+        }
+        System.out.println();
+    }
+}
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/README b/appserver/tests/embedded/cdi_ejb_jpa/README
new file mode 100644
index 0000000..3061290
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/README
@@ -0,0 +1,3 @@
+This test case tests CDI, EJB3, JPA2 components with embedded glassfish.
+In this test case, EJB TestBean is injected to BasicCDITestServlet via CDI, and the TestBean is adding/retrieving entries to the Entity Bean Person via JPA.
+The datasource is created via @DataSourceDefinition.
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/pom.xml b/appserver/tests/embedded/cdi_ejb_jpa/pom.xml
new file mode 100644
index 0000000..4d65ede
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.basic</groupId>
+    <artifactId>cdi_ejb_jpa</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>CDI, EJB, JPA integration test</name>
+    <build>
+        <finalName>cdi_ejb_jpa</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <forkMode>always</forkMode>
+                    <useSystemClassLoader>false</useSystemClassLoader>
+                    <useManifestOnlyJar>false</useManifestOnlyJar>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>${project.version}</version>
+                </dependency>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/config/.gitkeep_empty_dir b/appserver/tests/embedded/cdi_ejb_jpa/src/main/config/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/config/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITestServlet.java b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITestServlet.java
new file mode 100644
index 0000000..6d63192
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITestServlet.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.annotation.sql.DataSourceDefinition;
+
+@WebServlet(name = "BasicCDITestServlet",
+urlPatterns = "/BasicCDITestServlet")
+
+@DataSourceDefinition(
+            name="java:app/jdbc/DB1",
+            className="org.apache.derby.jdbc.EmbeddedDataSource",
+            portNumber=1527,
+            serverName="localhost",
+            databaseName="sun-appserv-samples",
+            user="APP",
+            password="APP",
+            properties={"connectionAttributes=;create=true"}
+)
+public class BasicCDITestServlet extends HttpServlet {
+
+    @javax.inject.Inject
+    TestBean testBean;
+
+    @javax.inject.Inject
+    TestRequestScopedBean trsb;
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+            HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+        out.println("Hi from BasicCDITestServlet");
+        if (testBean == null) {
+            out.println("TestBean not injected.");
+        } else if (trsb == null) {
+            out.println("TestRequestScopeBean not injected.");
+        } else {
+            out.println("TestBean injected. [" + testBean + "]");
+            out.println("TestRequestScopeBean injected. [ " + trsb + "]");
+            out.println("All CDI beans have been injected.");
+        }
+        invokeTestBean(out);
+        out.flush();
+        out.close();
+    }
+
+    private void invokeTestBean(PrintWriter out) {
+        testBean.addPerson("Ada");
+        testBean.addPerson("Bob");
+        testBean.addPerson("Cub");
+        out.println("Added persons.");
+
+        Person p1 = testBean.getPerson(1L);
+        Person p2 = testBean.getPerson(2L);
+        Person p3 = testBean.getPerson(3L);
+        out.println("Retrieved persons: " + p1 + ", " + p2 + ", " + p3);
+    }
+}
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/Person.java b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/Person.java
new file mode 100644
index 0000000..b2187ed
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/Person.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+import java.io.Serializable;
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Person implements Serializable {
+    private static final long serialVersionUID = 1L;
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private Long id;
+
+    @Basic
+    private String name;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 0;
+        hash += (id != null ? id.hashCode() : 0);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        // TODO: Warning - this method won't work in the case the id fields are not set
+        if (!(object instanceof Person)) {
+            return false;
+        }
+        Person other = (Person) object;
+        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "org.glassfish.tests.embedded.cdi_ejb_jpa.Person[id=" + id + "], [name=" +
+                getName() + "]";
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestBean.java b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestBean.java
new file mode 100644
index 0000000..549780d
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestBean.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+//Simple TestBean to test CDI. 
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+@Stateless
+public class TestBean {
+    @PersistenceContext()
+    private EntityManager em;
+
+    public void addPerson(String name) {
+        Person p = new Person();
+        p.setName(name);
+        em.persist(p);
+    }
+
+    public Person getPerson(Long pid) {
+        return em.find(Person.class, pid);
+    }
+
+    public void removePerson(Long pid) {
+        Person p = getPerson(pid);
+        if(p != null) {
+            em.remove(p);
+        }
+    }
+
+    public void removePerson(Person p) {
+        em.remove(p);
+    }
+}
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestRequestScopedBean.java b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestRequestScopedBean.java
new file mode 100644
index 0000000..5dd4628
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestRequestScopedBean.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+//Simple RequestScoped TestBean to test CDI. 
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+@javax.enterprise.context.RequestScoped
+public class TestRequestScopedBean
+{}
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/resources/META-INF/persistence.xml b/appserver/tests/embedded/cdi_ejb_jpa/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..23d971c
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+  <persistence-unit name="cdi_ejb_jpa_pu" transaction-type="JTA">
+    <jta-data-source>java:app/jdbc/DB1</jta-data-source>
+    <properties>
+      <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+      <property name="eclipselink.logging.level" value="FINE"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/beans.xml b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/beans.xml
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..0105a07
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>/cdi_ejb_jpa</context-root> 
+</sun-web-app>
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..6c0e313
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+  <display-name>cdi_ejb_jpa</display-name>  
+  <distributable/>
+</web-app>
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/images/.gitkeep_empty_dir b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/images/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/main/webapp/images/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/cdi_ejb_jpa/src/test/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITest.java b/appserver/tests/embedded/cdi_ejb_jpa/src/test/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITest.java
new file mode 100644
index 0000000..638dc9e
--- /dev/null
+++ b/appserver/tests/embedded/cdi_ejb_jpa/src/test/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+import junit.framework.Assert;
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishProperties;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.glassfish.embeddable.archive.ScatteredArchive;
+import org.glassfish.embeddable.archive.ScatteredEnterpriseArchive;
+import org.glassfish.embeddable.web.HttpListener;
+import org.glassfish.embeddable.web.WebContainer;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class BasicCDITest{
+
+    @Test
+    public void test() throws Exception {
+
+        GlassFishProperties props = new GlassFishProperties();
+        props.setPort("http-listener", 8080);
+        GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(props);
+        glassfish.start();
+
+        // Test Scattered Web Archive
+        ScatteredArchive sa = new ScatteredArchive("cdi_ejb_jpa",
+                ScatteredArchive.Type.WAR, new File("src/main/webapp"));
+        sa.addClassPath(new File("target/classes"));
+        sa.addClassPath(new File("src/main/resources"));
+        URI warURI = sa.toURI();
+        printContents(warURI);
+
+        // Deploy archive
+        Deployer deployer = glassfish.getDeployer();
+        String appname = deployer.deploy(warURI);
+        System.out.println("Deployed [" + appname + "]");
+        Assert.assertEquals(appname, "cdi_ejb_jpa");
+
+        // Now create a http listener and access the app.
+        WebContainer webcontainer = glassfish.getService(WebContainer.class);
+        HttpListener listener = new HttpListener();
+        listener.setId("my-listener");
+        listener.setPort(9090);
+        webcontainer.addWebListener(listener);
+
+        get("http://localhost:8080/cdi_ejb_jpa/BasicCDITestServlet",
+                "All CDI beans have been injected.");
+
+        deployer.undeploy(appname);
+
+        glassfish.dispose();
+
+    }
+
+    private void get(String urlStr, String result) throws Exception {
+        URL url = new URL(urlStr);
+        URLConnection yc = url.openConnection();
+        System.out.println("\nURLConnection [" + yc + "] : ");
+        BufferedReader in = new BufferedReader(new InputStreamReader(
+                yc.getInputStream()));
+        String line = null;
+        boolean found = false;
+        while ((line = in.readLine()) != null) {
+            System.out.println(line);
+            if (line.indexOf(result) != -1) {
+                found = true;
+            }
+        }
+        Assert.assertTrue(found);
+        System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+    }
+
+    void printContents(URI jarURI) throws IOException {
+        JarFile jarfile = new JarFile(new File(jarURI));
+        System.out.println("\n\n[" + jarURI + "] contents : \n");
+        Enumeration<JarEntry> entries = jarfile.entries();
+        while (entries.hasMoreElements()) {
+            JarEntry entry = entries.nextElement();
+            System.out.println(entry.getSize() + "\t" + new Date(entry.getTime()) +
+                    "\t" + entry.getName());
+        }
+        System.out.println();
+    }
+}
diff --git a/appserver/tests/embedded/ejb/basic/pom.xml b/appserver/tests/embedded/ejb/basic/pom.xml
new file mode 100644
index 0000000..a7f7b31
--- /dev/null
+++ b/appserver/tests/embedded/ejb/basic/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.ejb</groupId>
+    <artifactId>basic</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Test HelloWorld and Timer EJB deployed with org.glassfish.embeddable APIs</name>
+  <build>
+    <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+            </plugin>
+     <plugin>
+       <groupId>org.apache.maven.plugins</groupId>
+       <artifactId>maven-jar-plugin</artifactId>
+       <version>3.1.0</version>
+       <executions>
+         <execution>
+           <goals>
+             <goal>test-jar</goal>
+           </goals>
+         </execution>
+       </executions>
+     </plugin>
+    </plugins>
+  </build>    
+  <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>    
+	<dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+        </dependency>
+    </dependencies>    
+
+</project>
diff --git a/appserver/tests/embedded/ejb/basic/src/main/java/org/glassfish/tests/embedded/ejb/basic/SampleEjb.java b/appserver/tests/embedded/ejb/basic/src/main/java/org/glassfish/tests/embedded/ejb/basic/SampleEjb.java
new file mode 100644
index 0000000..1b00294
--- /dev/null
+++ b/appserver/tests/embedded/ejb/basic/src/main/java/org/glassfish/tests/embedded/ejb/basic/SampleEjb.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.basic;
+
+import javax.ejb.Stateless;
+
+/**
+ * @author Jerome Dochez
+ */
+@Stateless
+public class SampleEjb {
+
+    public String saySomething() {
+        String hello = "Hello World";
+        System.out.println(hello);
+        return hello;
+    }
+}
diff --git a/appserver/tests/embedded/ejb/basic/src/main/java/org/glassfish/tests/embedded/ejb/basic/TimerEjb.java b/appserver/tests/embedded/ejb/basic/src/main/java/org/glassfish/tests/embedded/ejb/basic/TimerEjb.java
new file mode 100644
index 0000000..9b727ec
--- /dev/null
+++ b/appserver/tests/embedded/ejb/basic/src/main/java/org/glassfish/tests/embedded/ejb/basic/TimerEjb.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.basic;
+
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.ejb.Schedule;
+import javax.naming.InitialContext;
+
+@Stateless
+public class TimerEjb {
+
+    private static volatile boolean timeoutWasCalled = false;
+    private static volatile boolean autotimeoutWasCalled = false;
+
+    public void createTimer() throws Exception {
+        System.err.println("In SimpleEjb:createTimer()");
+        TimerService timerSvc = (TimerService) new InitialContext().lookup(
+                "java:comp/TimerService");
+        Timer t = timerSvc.createTimer(2, "timer01");
+    }
+
+    public boolean verifyTimer() {
+        return timeoutWasCalled && autotimeoutWasCalled;
+    }
+
+    @Timeout
+    private void timeout(Timer t) {
+
+        System.err.println("in SimpleEjb: timeout " + t.getInfo());
+        timeoutWasCalled = true;
+    }
+
+    @Schedule(second = "*", minute = "*", hour = "*")
+    public void autotest() {
+        System.err.println("IN AUTO-TIMEOUT!!!");
+        autotimeoutWasCalled = true;
+    }
+}
diff --git a/appserver/tests/embedded/ejb/basic/src/test/java/org/glassfish/tests/embedded/ejb/basic/test/EmbeddedTest.java b/appserver/tests/embedded/ejb/basic/src/test/java/org/glassfish/tests/embedded/ejb/basic/test/EmbeddedTest.java
new file mode 100644
index 0000000..1d21cbf
--- /dev/null
+++ b/appserver/tests/embedded/ejb/basic/src/test/java/org/glassfish/tests/embedded/ejb/basic/test/EmbeddedTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.basic.test;
+
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.glassfish.tests.embedded.ejb.basic.SampleEjb;
+import org.glassfish.tests.embedded.ejb.basic.TimerEjb;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.naming.InitialContext;
+import java.io.File;
+import java.net.URI;
+
+/**
+ * this test will use the ejb API testing.
+ *
+ * @author Jerome Dochez
+ * @author bhavanishankar@dev.java.net
+ */
+public class EmbeddedTest {
+
+/*
+    public static void main(String[] args) {
+        EmbeddedTest test = new EmbeddedTest();
+        System.setProperty("basedir", System.getProperty());
+        test.test();        
+    }
+*/
+
+    @Test
+    public void test() throws Exception {
+        GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+
+
+        Deployer deployer = glassfish.getDeployer();
+        URI uri = new File(System.getProperty("user.dir"), "target/classes").toURI();
+        System.out.println("Deploying [" + uri + "]");
+        deployer.deploy(uri);
+
+        InitialContext ic = new InitialContext();
+
+        System.out.println("Looking up SampleEJB.");
+        SampleEjb sampleEjb = (SampleEjb) ic.lookup("java:global/classes/SampleEjb");
+        System.out.println("Invoking SampleEjb [" + sampleEjb + "]");
+        Assert.assertEquals(sampleEjb.saySomething(), "Hello World");
+        System.out.println("SampleEjb tested successfully");
+
+        System.out.println("Looking up TimerEjb.");
+        TimerEjb timerEjb = (TimerEjb) ic.lookup("java:global/classes/TimerEjb");
+        System.out.println("Invoking TimerEjb [" + timerEjb + "]");
+        timerEjb.createTimer();
+        System.out.println("Verifying TimerEjb [" + timerEjb + "]");
+        Thread.sleep(4000);
+        boolean result = timerEjb.verifyTimer();
+        Assert.assertTrue(result);
+        System.out.println("TimerEJB tested successfully.");
+
+        glassfish.stop();
+        glassfish.dispose();
+        
+        System.out.println("EmbeddedTest completed.");
+
+    }
+}
diff --git a/appserver/tests/embedded/ejb/ejb-api/pom.xml b/appserver/tests/embedded/ejb/ejb-api/pom.xml
new file mode 100644
index 0000000..b04c180
--- /dev/null
+++ b/appserver/tests/embedded/ejb/ejb-api/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.ejb</groupId>
+    <artifactId>ejb-api-test</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>EJB Embedded API test</name>
+  <build>
+    <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+     <plugin>
+       <groupId>org.apache.maven.plugins</groupId>
+       <artifactId>maven-jar-plugin</artifactId>
+       <version>3.1.0</version>
+       <executions>
+         <execution>
+           <goals>
+             <goal>test-jar</goal>
+           </goals>
+         </execution>
+       </executions>
+     </plugin>
+    </plugins>
+  </build>    
+  <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+	<dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+        </dependency>
+    </dependencies>    
+
+</project>
diff --git a/appserver/tests/embedded/ejb/ejb-api/src/main/java/org/glassfish/tests/embedded/ejb/SampleEjb.java b/appserver/tests/embedded/ejb/ejb-api/src/main/java/org/glassfish/tests/embedded/ejb/SampleEjb.java
new file mode 100644
index 0000000..fa168aa
--- /dev/null
+++ b/appserver/tests/embedded/ejb/ejb-api/src/main/java/org/glassfish/tests/embedded/ejb/SampleEjb.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb;
+
+import javax.ejb.Stateless;
+
+/**
+ * @author Jerome Dochez
+ */
+@Stateless
+public class SampleEjb {
+
+    public String saySomething() {
+        return "Hello World";
+    }
+}
diff --git a/appserver/tests/embedded/ejb/ejb-api/src/test/java/org/glassfish/tests/embedded/ejb/test/EmbeddedTest.java b/appserver/tests/embedded/ejb/ejb-api/src/test/java/org/glassfish/tests/embedded/ejb/test/EmbeddedTest.java
new file mode 100644
index 0000000..08a24e2
--- /dev/null
+++ b/appserver/tests/embedded/ejb/ejb-api/src/test/java/org/glassfish/tests/embedded/ejb/test/EmbeddedTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.test;
+
+import org.junit.Test;
+import org.junit.Assert;
+import org.glassfish.tests.embedded.ejb.SampleEjb;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.*;
+
+/**
+ * this test will use the ejb API testing.
+ *
+ * @author Jerome Dochez
+ */
+public class EmbeddedTest {
+
+    public static void main(String[] args) {
+        EmbeddedTest test = new EmbeddedTest();
+        System.setProperty("basedir", System.getProperty("user.dir"));
+        test.test();        
+    }
+
+    public File getDeployableArtifact() {
+        File f = new File(System.getProperty("basedir"), "target");
+        f = new File(f, "classes");        
+        return f;
+    }
+
+    @Test
+    public void test() {
+        Map<String, Object> p = new HashMap<String, Object>();
+        p.put(EJBContainer.MODULES, getDeployableArtifact());
+
+        try {
+            EJBContainer c = EJBContainer.createEJBContainer(p);
+            try {
+                Context ic = c.getContext();
+                try {
+                    System.out.println("Looking up EJB...");
+                    SampleEjb ejb = (SampleEjb) ic.lookup("java:global/classes/SampleEjb");
+                    if (ejb!=null) {
+                        System.out.println("Invoking EJB...");
+                        System.out.println(ejb.saySomething());
+                        Assert.assertEquals(ejb.saySomething(), "Hello World");
+                    }
+                } catch (Exception e) {
+                    System.out.println("ERROR calling EJB:");
+                    e.printStackTrace();
+                    throw new RuntimeException(e);
+                }
+                System.out.println("Done calling EJB");
+            } finally {
+                c.close();
+            }
+        } catch(Exception e) {
+            System.out.println("Error setting up EJB container");
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        }
+    }
+}
diff --git a/appserver/tests/embedded/ejb/ejb-main/pom.xml b/appserver/tests/embedded/ejb/ejb-main/pom.xml
new file mode 100644
index 0000000..6247428
--- /dev/null
+++ b/appserver/tests/embedded/ejb/ejb-main/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>ejb</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.ejb</groupId>
+    <artifactId>ejb-main-test</artifactId>
+    <name>EJB Embedded API In a standalone program</name>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.1.1</version>
+          <executions>
+              <execution>
+                  <phase>test</phase>
+                  <goals>
+                      <goal>exec</goal>
+                  </goals>
+              </execution>
+          </executions>
+          <configuration>
+              <executable>java</executable>
+              <arguments>
+                  <argument>-classpath</argument>
+                  <classpath/>
+                  <argument>org.glassfish.tests.embedded.ejb.main.EmbeddedMainTest</argument>
+              </arguments>
+              <classpathScope>test</classpathScope>
+              <includeProjectDependencies>true</includeProjectDependencies>
+          </configuration>
+      </plugin>
+    </plugins>
+  </build>
+          <dependencies>
+            <dependency>
+                <groupId>org.glassfish.tests.embedded.ejb</groupId>
+                <artifactId>ejb-api-test</artifactId>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.glassfish.tests.embedded.ejb</groupId>
+                <artifactId>ejb-api-test</artifactId>
+                <version>${project.version}</version>
+                <classifier>tests</classifier>
+                <scope>test</scope>
+            </dependency>              
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>4.12</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.glassfish.main.extras</groupId>
+                <artifactId>glassfish-embedded-web</artifactId>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
+          </dependencies> 
+</project>
diff --git a/appserver/tests/embedded/ejb/ejb-main/src/test/java/org/glassfish/tests/embedded/ejb/main/EmbeddedMainTest.java b/appserver/tests/embedded/ejb/ejb-main/src/test/java/org/glassfish/tests/embedded/ejb/main/EmbeddedMainTest.java
new file mode 100644
index 0000000..81a3e18
--- /dev/null
+++ b/appserver/tests/embedded/ejb/ejb-main/src/test/java/org/glassfish/tests/embedded/ejb/main/EmbeddedMainTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.main;
+
+import org.glassfish.tests.embedded.ejb.test.*;
+
+import java.io.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dochez
+ * Date: Nov 2, 2009
+ * Time: 10:20:01 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class EmbeddedMainTest extends EmbeddedTest {
+
+    public static void main(String[] args) {
+        EmbeddedMainTest test = new EmbeddedMainTest();
+        System.setProperty("basedir", System.getProperty("user.dir"));
+        test.test();
+    }
+
+    @Override
+    public File getDeployableArtifact() {
+        File f = new File(System.getProperty("basedir"));
+        f = f.getParentFile();
+        f = new File(f, "ejb-api");
+        f = new File(f, "target");
+        f = new File(f, "classes");
+        System.out.println("Using file " + f.getAbsolutePath());
+        return f;
+    }
+}
diff --git a/appserver/tests/embedded/ejb/pom.xml b/appserver/tests/embedded/ejb/pom.xml
new file mode 100755
index 0000000..9bcae52
--- /dev/null
+++ b/appserver/tests/embedded/ejb/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>ejb</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>EJB related Embedded Tests</name>  
+    <modules>
+    	<module>basic</module>
+        <module>ejb-api</module>
+        <module>remoteejb</module>
+    </modules>
+</project>
diff --git a/appserver/tests/embedded/ejb/remoteejb/pom.xml b/appserver/tests/embedded/ejb/remoteejb/pom.xml
new file mode 100644
index 0000000..d0eaa1b
--- /dev/null
+++ b/appserver/tests/embedded/ejb/remoteejb/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.ejb</groupId>
+    <artifactId>remoteejb</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Test remote EJB deployment with org.glassfish.embeddable APIs</name>
+    <build>
+        <finalName>remoteejb</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <parallel>method</parallel>
+                    <threadCount>1</threadCount>
+                    <skip>true</skip>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <parallel>method</parallel>
+                            <threadCount>1</threadCount>
+                            <skip>false</skip>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>    
+	<dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+        </dependency>
+    </dependencies>    
+
+</project>
diff --git a/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/RemoteEJB.java b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/RemoteEJB.java
new file mode 100644
index 0000000..e3a5ba0
--- /dev/null
+++ b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/RemoteEJB.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.remoteejb;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+@Stateless
+@Remote(RemoteEJBInf.class)
+public class RemoteEJB {
+
+    public String sayHi() {
+        return "Hi Bhavani";
+    }
+
+}
+
diff --git a/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/RemoteEJBInf.java b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/RemoteEJBInf.java
new file mode 100644
index 0000000..3fefea1
--- /dev/null
+++ b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/RemoteEJBInf.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.remoteejb;
+
+public interface RemoteEJBInf {
+
+  public String sayHi();
+
+}
+
diff --git a/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/SampleEjb.java b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/SampleEjb.java
new file mode 100644
index 0000000..4451766
--- /dev/null
+++ b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/SampleEjb.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.remoteejb;
+
+import javax.ejb.Stateless;
+
+/**
+ * @author Jerome Dochez
+ */
+@Stateless
+public class SampleEjb {
+
+    public String saySomething() {
+        String hello = "Hello World";
+        System.out.println(hello);
+        return hello;
+    }
+}
diff --git a/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/TimerEjb.java b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/TimerEjb.java
new file mode 100644
index 0000000..dca712c
--- /dev/null
+++ b/appserver/tests/embedded/ejb/remoteejb/src/main/java/org/glassfish/tests/embedded/ejb/remoteejb/TimerEjb.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.remoteejb;
+
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.ejb.Schedule;
+import javax.naming.InitialContext;
+
+@Stateless
+public class TimerEjb {
+
+    private static volatile boolean timeoutWasCalled = false;
+    private static volatile boolean autotimeoutWasCalled = false;
+
+    public void createTimer() throws Exception {
+        System.err.println("In SimpleEjb:createTimer()");
+        TimerService timerSvc = (TimerService) new InitialContext().lookup(
+                "java:comp/TimerService");
+        Timer t = timerSvc.createTimer(2, "timer01");
+    }
+
+    public boolean verifyTimer() {
+        return timeoutWasCalled && autotimeoutWasCalled;
+    }
+
+    @Timeout
+    private void timeout(Timer t) {
+
+        System.err.println("in SimpleEjb: timeout " + t.getInfo());
+        timeoutWasCalled = true;
+    }
+
+    @Schedule(second = "*", minute = "*", hour = "*")
+    public void autotest() {
+        System.err.println("IN AUTO-TIMEOUT!!!");
+        autotimeoutWasCalled = true;
+    }
+}
diff --git a/appserver/tests/embedded/ejb/remoteejb/src/test/java/org/glassfish/tests/embedded/ejb/remoteejb/test/EJBTest.java b/appserver/tests/embedded/ejb/remoteejb/src/test/java/org/glassfish/tests/embedded/ejb/remoteejb/test/EJBTest.java
new file mode 100644
index 0000000..f067ad3
--- /dev/null
+++ b/appserver/tests/embedded/ejb/remoteejb/src/test/java/org/glassfish/tests/embedded/ejb/remoteejb/test/EJBTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.remoteejb.test;
+
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.glassfish.tests.embedded.ejb.remoteejb.RemoteEJBInf;
+import org.glassfish.tests.embedded.ejb.remoteejb.SampleEjb;
+import org.glassfish.tests.embedded.ejb.remoteejb.TimerEjb;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.naming.InitialContext;
+import java.io.File;
+import java.net.URI;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+public class EJBTest {
+
+    /*
+        public static void main(String[] args) {
+            EmbeddedTest test = new EmbeddedTest();
+            System.setProperty("basedir", System.getProperty());
+            test.test();
+        }
+    */
+    GlassFish glassfish;
+
+    @Test
+    public void test() throws Exception {
+
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+
+
+        Deployer deployer = glassfish.getDeployer();
+        URI uri = new File(System.getProperty("user.dir"), "target/remoteejb.jar").toURI();
+        System.out.println("Deploying [" + uri + "]");
+        deployer.deploy(uri);
+
+        InitialContext ic = new InitialContext();
+
+        System.out.println("Looking up SampleEJB.");
+        SampleEjb sampleEjb = (SampleEjb) ic.lookup("java:global/remoteejb/SampleEjb");
+        System.out.println("Invoking SampleEjb [" + sampleEjb + "]");
+        Assert.assertEquals(sampleEjb.saySomething(), "Hello World");
+        System.out.println("SampleEjb tested successfully");
+
+        System.out.println("Looking up TimerEjb.");
+        TimerEjb timerEjb = (TimerEjb) ic.lookup("java:global/remoteejb/TimerEjb");
+        System.out.println("Invoking TimerEjb [" + timerEjb + "]");
+        timerEjb.createTimer();
+        System.out.println("Verifying TimerEjb [" + timerEjb + "]");
+        Thread.sleep(4000);
+        boolean result = timerEjb.verifyTimer();
+        Assert.assertTrue(result);
+        System.out.println("TimerEJB tested successfully.");
+
+
+//        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+//        try {
+            System.out.println("Looking up RemoteEJB.");
+//            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+            RemoteEJBInf remoteEjb = (RemoteEJBInf) ic.lookup("java:global/remoteejb/RemoteEJB");
+            System.out.println("Invoking RemoteEJB [" + remoteEjb + "]");
+            Assert.assertEquals(remoteEjb.sayHi(), "Hi Bhavani");
+            System.out.println("RemoteEjb tested successfully");
+//        } finally {
+//            Thread.currentThread().setContextClassLoader(oldCL);
+//        }
+        
+        glassfish.stop();
+        glassfish.dispose();
+
+        System.out.println("EmbeddedTest completed.");
+
+    }
+
+    @Test
+    public void test2() throws Exception {
+
+    }
+
+}
diff --git a/appserver/tests/embedded/glassfish_resources_xml/README b/appserver/tests/embedded/glassfish_resources_xml/README
new file mode 100644
index 0000000..7c2cafe
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/README
@@ -0,0 +1 @@
+This test case is a variant of cdi_ejb_jpa test. It tests the same test scenariobut the datasource is created via glassfish-resources.xml.
diff --git a/appserver/tests/embedded/glassfish_resources_xml/pom.xml b/appserver/tests/embedded/glassfish_resources_xml/pom.xml
new file mode 100644
index 0000000..85c4818
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.basic</groupId>
+    <artifactId>glassfish_resources_xml</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>CDI, EJB, JPA integration test which has glassfish-resources.xml</name>
+    <build>
+        <finalName>glassfish_resources_xml</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <forkMode>always</forkMode>
+                    <useSystemClassLoader>false</useSystemClassLoader>
+                    <useManifestOnlyJar>false</useManifestOnlyJar>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>${project.version}</version>
+                </dependency>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+</project>
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/config/.gitkeep_empty_dir b/appserver/tests/embedded/glassfish_resources_xml/src/main/config/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/config/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITestServlet.java b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITestServlet.java
new file mode 100644
index 0000000..badcaac
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITestServlet.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "BasicCDITestServlet",
+urlPatterns = "/BasicCDITestServlet")
+
+public class BasicCDITestServlet extends HttpServlet {
+
+    @javax.inject.Inject
+    TestBean testBean;
+
+    @javax.inject.Inject
+    TestRequestScopedBean trsb;
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+            HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+        out.println("Hi from BasicCDITestServlet");
+        if (testBean == null) {
+            out.println("TestBean not injected.");
+        } else if (trsb == null) {
+            out.println("TestRequestScopeBean not injected.");
+        } else {
+            out.println("TestBean injected. [" + testBean + "]");
+            out.println("TestRequestScopeBean injected. [ " + trsb + "]");
+            out.println("All CDI beans have been injected.");
+        }
+        invokeTestBean(out);
+        out.flush();
+        out.close();
+    }
+
+    private void invokeTestBean(PrintWriter out) {
+        testBean.addPerson("Ada");
+        testBean.addPerson("Bob");
+        testBean.addPerson("Cub");
+        out.println("Added persons.");
+
+        Person p1 = testBean.getPerson(1L);
+        Person p2 = testBean.getPerson(2L);
+        Person p3 = testBean.getPerson(3L);
+        out.println("Retrieved persons: " + p1 + ", " + p2 + ", " + p3);
+    }
+}
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/Person.java b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/Person.java
new file mode 100644
index 0000000..b2187ed
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/Person.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+import java.io.Serializable;
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Person implements Serializable {
+    private static final long serialVersionUID = 1L;
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private Long id;
+
+    @Basic
+    private String name;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 0;
+        hash += (id != null ? id.hashCode() : 0);
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object object) {
+        // TODO: Warning - this method won't work in the case the id fields are not set
+        if (!(object instanceof Person)) {
+            return false;
+        }
+        Person other = (Person) object;
+        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "org.glassfish.tests.embedded.cdi_ejb_jpa.Person[id=" + id + "], [name=" +
+                getName() + "]";
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestBean.java b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestBean.java
new file mode 100644
index 0000000..549780d
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestBean.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+//Simple TestBean to test CDI. 
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+@Stateless
+public class TestBean {
+    @PersistenceContext()
+    private EntityManager em;
+
+    public void addPerson(String name) {
+        Person p = new Person();
+        p.setName(name);
+        em.persist(p);
+    }
+
+    public Person getPerson(Long pid) {
+        return em.find(Person.class, pid);
+    }
+
+    public void removePerson(Long pid) {
+        Person p = getPerson(pid);
+        if(p != null) {
+            em.remove(p);
+        }
+    }
+
+    public void removePerson(Person p) {
+        em.remove(p);
+    }
+}
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestRequestScopedBean.java b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestRequestScopedBean.java
new file mode 100644
index 0000000..5dd4628
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/java/org/glassfish/tests/embedded/cdi_ejb_jpa/TestRequestScopedBean.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+//Simple RequestScoped TestBean to test CDI. 
+//This bean implements Serializable as it needs to be placed into a Stateful Bean
+@javax.enterprise.context.RequestScoped
+public class TestRequestScopedBean
+{}
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/resources/META-INF/persistence.xml b/appserver/tests/embedded/glassfish_resources_xml/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..23d971c
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+  <persistence-unit name="cdi_ejb_jpa_pu" transaction-type="JTA">
+    <jta-data-source>java:app/jdbc/DB1</jta-data-source>
+    <properties>
+      <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+      <property name="eclipselink.logging.level" value="FINE"/>
+    </properties>
+  </persistence-unit>
+</persistence>
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/beans.xml b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/beans.xml
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/glassfish-resources.xml b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/glassfish-resources.xml
new file mode 100644
index 0000000..78ae1a8
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/glassfish-resources.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
+
+<resources>
+ <jdbc-connection-pool pool-resize-quantity="1" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource" max-pool-size="5" res-type="javax.sql.DataSource" steady-pool-size="0" statement-timeout-in-seconds="30" name="java:app/jdbc/cdi_ejb_jpa_pool">
+      <property name="User" value="APP"></property>
+      <property name="Password" value="APP"></property>
+      <property name="driverType" value="4"></property>
+      <property name="portNumber" value="1527"></property>
+      <property name="dataBaseName" value="sun-appserv-samples"></property>
+      <property name="create" value="true"></property>
+      <property name="serverName" value="localhost"></property>
+      <property name="connectionAttributes" value=";create=true"></property>
+    </jdbc-connection-pool>
+
+    <jdbc-resource pool-name="java:app/jdbc/cdi_ejb_jpa_pool" jndi-name="java:app/jdbc/DB1"></jdbc-resource>
+
+</resources>
+
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..0105a07
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>/cdi_ejb_jpa</context-root> 
+</sun-web-app>
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..6c0e313
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+  <display-name>cdi_ejb_jpa</display-name>  
+  <distributable/>
+</web-app>
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/images/.gitkeep_empty_dir b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/images/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/main/webapp/images/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/glassfish_resources_xml/src/test/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITest.java b/appserver/tests/embedded/glassfish_resources_xml/src/test/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITest.java
new file mode 100644
index 0000000..2c2047d
--- /dev/null
+++ b/appserver/tests/embedded/glassfish_resources_xml/src/test/java/org/glassfish/tests/embedded/cdi_ejb_jpa/BasicCDITest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cdi_ejb_jpa;
+
+import junit.framework.Assert;
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishProperties;
+import org.glassfish.embeddable.BootstrapProperties;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.glassfish.embeddable.archive.ScatteredArchive;
+import org.glassfish.embeddable.archive.ScatteredEnterpriseArchive;
+import org.glassfish.embeddable.web.HttpListener;
+import org.glassfish.embeddable.web.WebContainer;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class BasicCDITest{
+
+    @Test
+    public void test() throws Exception {
+
+        GlassFishProperties props = new GlassFishProperties();
+        BootstrapProperties bootstrapProperties = new BootstrapProperties();
+        props.setPort("http-listener", 8080);
+        GlassFish glassfish = GlassFishRuntime.bootstrap(bootstrapProperties).newGlassFish(props);
+        glassfish.start();
+
+        // Test Scattered Web Archive
+        ScatteredArchive sa = new ScatteredArchive("cdi_ejb_jpa",
+                ScatteredArchive.Type.WAR, new File("src/main/webapp"));
+        sa.addClassPath(new File("target/classes"));
+        sa.addClassPath(new File("src/main/resources"));
+        URI warURI = sa.toURI();
+        printContents(warURI);
+
+        // Deploy archive
+        Deployer deployer = glassfish.getDeployer();
+        String appname = deployer.deploy(warURI);
+        System.out.println("Deployed [" + appname + "]");
+        Assert.assertEquals(appname, "cdi_ejb_jpa");
+
+        // Now create a http listener and access the app.
+        WebContainer webcontainer = glassfish.getService(WebContainer.class);
+        HttpListener listener = new HttpListener();
+        listener.setId("my-listener");
+        listener.setPort(9090);
+        webcontainer.addWebListener(listener);
+
+        get("http://localhost:8080/cdi_ejb_jpa/BasicCDITestServlet",
+                "All CDI beans have been injected.");
+
+        deployer.undeploy(appname);
+
+        glassfish.dispose();
+
+    }
+
+    private void get(String urlStr, String result) throws Exception {
+        URL url = new URL(urlStr);
+        URLConnection yc = url.openConnection();
+        System.out.println("\nURLConnection [" + yc + "] : ");
+        BufferedReader in = new BufferedReader(new InputStreamReader(
+                yc.getInputStream()));
+        String line = null;
+        boolean found = false;
+        while ((line = in.readLine()) != null) {
+            System.out.println(line);
+            if (line.indexOf(result) != -1) {
+                found = true;
+            }
+        }
+        Assert.assertTrue(found);
+        System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+    }
+
+    void printContents(URI jarURI) throws IOException {
+        JarFile jarfile = new JarFile(new File(jarURI));
+        System.out.println("\n\n[" + jarURI + "] contents : \n");
+        Enumeration<JarEntry> entries = jarfile.entries();
+        while (entries.hasMoreElements()) {
+            JarEntry entry = entries.nextElement();
+            System.out.println(entry.getSize() + "\t" + new Date(entry.getTime()) +
+                    "\t" + entry.getName());
+        }
+        System.out.println();
+    }
+}
diff --git a/appserver/tests/embedded/inplanted/pom.xml b/appserver/tests/embedded/inplanted/pom.xml
new file mode 100755
index 0000000..8fc49a9
--- /dev/null
+++ b/appserver/tests/embedded/inplanted/pom.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.glassfish.main</groupId>
+        <artifactId>glassfish-parent</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>inplanted</artifactId>
+    <name>Inplanted mode embedded testing</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy</id>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.glassfish.main.distributions</groupId>
+                  <artifactId>web</artifactId>
+                  <version>${project.version}</version>
+                  <type>zip</type>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.4.2</version>
+        <configuration>
+          <forkMode>always</forkMode>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>                
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>                
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>    
+    <dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.12</version>
+		</dependency>
+        <dependency>
+            <groupId>org.glassfish.main.web</groupId>
+            <artifactId>web-embed-api</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.htmlunit</groupId>
+            <artifactId>htmlunit</artifactId>
+            <version>2.29</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.main.tests.embedded</groupId>
+            <artifactId>utils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+   </dependencies>
+</project>
diff --git a/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/ExistingConfigurationTest.java b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/ExistingConfigurationTest.java
new file mode 100644
index 0000000..9342869
--- /dev/null
+++ b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/ExistingConfigurationTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.inplanted;
+
+import org.glassfish.hk2.api.ServiceHandle;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.tests.embedded.utils.EmbeddedServerUtils;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Collection;
+import java.lang.reflect.Method;
+
+/**
+ * @author Jerome Dochez
+ */
+public class ExistingConfigurationTest {
+
+    @Test
+    public void setupServer() throws Exception {
+
+        Server server=null;
+        Port port = null;
+
+        File f = EmbeddedServerUtils.getServerLocation();
+        try {
+            EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
+            efsb.installRoot(f);
+            // find the domain root.
+            f = EmbeddedServerUtils.getDomainLocation(f);
+            f = new File(f, "config");
+            f = new File(f, "domain.xml");
+            Assert.assertTrue(f.exists());
+            efsb.configurationFile(f, true);
+            server = EmbeddedServerUtils.createServer(efsb.build());
+
+            ServiceLocator habitat = server.getHabitat();
+            Collection<ServiceHandle<?>> vss = habitat.getAllServiceHandles(com.sun.enterprise.config.serverbeans.VirtualServer.class);
+            Assert.assertTrue(vss.size()>0);
+            for (ServiceHandle<?> vs : vss ) {
+                Object virtualServer = vs.getService();
+                Method m = virtualServer.getClass().getMethod("getId");
+                Assert.assertNotNull("Object returned does not implement getId, is it a virtual server ?", m);
+                String id = (String) m.invoke(virtualServer);
+                System.out.println("Virtual Server " + id);
+                Assert.assertNotNull("Got a null virtual server ID", id);
+            }
+            Collection<ServiceHandle<?>> nls = habitat.getAllServiceHandles(org.glassfish.grizzly.config.dom.NetworkListener.class);
+            Assert.assertTrue(nls.size()>1);
+            for (ServiceHandle<?> nl : nls) {
+                Object networkListener = nl.getService();
+                Method m = networkListener.getClass().getMethod("getPort");
+                Assert.assertNotNull("Object returned does not implement getPort, is it a networkListener ?", m);
+                String p = (String) m.invoke(networkListener);
+                System.out.println("Network Listener " + p);
+                Assert.assertNotNull("Got a null networkListener port", p);
+            }
+            server.start();
+            port = server.createPort(8758);
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        } finally {
+            if (port!=null) {
+                port.close();
+            }
+            EmbeddedServerUtils.shutdownServer(server);
+        }
+    }
+}
diff --git a/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/ExistingDomainTest.java b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/ExistingDomainTest.java
new file mode 100644
index 0000000..bf793a0
--- /dev/null
+++ b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/ExistingDomainTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.inplanted;
+
+import org.glassfish.hk2.api.ServiceHandle;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.api.admin.*;
+import org.glassfish.api.container.Sniffer;
+import org.glassfish.tests.embedded.utils.EmbeddedServerUtils;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.AfterClass;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Collection;
+import java.lang.reflect.Method;
+
+/**
+ * Test embedded API with an existing domain.xml
+ *
+ * @author Jerome Dochez
+ */
+public class ExistingDomainTest {
+    static Server server;
+
+    @BeforeClass
+    public static void setupServer() throws Exception {
+        File serverLocation = EmbeddedServerUtils.getServerLocation();
+        EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
+        efsb.installRoot(serverLocation).instanceRoot(EmbeddedServerUtils.getDomainLocation(serverLocation));
+        server = EmbeddedServerUtils.createServer(efsb.build());
+    }
+
+    @Test
+    public void Test() throws Exception {
+
+        ServiceLocator habitat = server.getHabitat();
+        System.out.println("Process type is " + habitat.<ProcessEnvironment>getService(ProcessEnvironment.class).getProcessType());
+        Collection<ServiceHandle<?>> listeners = habitat.getAllServiceHandles(org.glassfish.grizzly.config.dom.NetworkListener.class);
+        Assert.assertTrue(listeners.size()>1);
+        for (ServiceHandle<?> s : listeners) {
+            Object networkListener = s.getService();
+            Method m = networkListener.getClass().getMethod("getPort");
+            Assert.assertNotNull("Object returned does not implement getPort, is it a networkListener ?", m);
+            String port = (String) m.invoke(networkListener);
+            System.out.println("Network Listener " + port);
+            Assert.assertNotNull("Got a null networkListener port", port);
+        }
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws Exception {
+        EmbeddedServerUtils.shutdownServer(server);
+    }
+    
+}
diff --git a/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/InplantedTest.java b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/InplantedTest.java
new file mode 100644
index 0000000..a46d7a2
--- /dev/null
+++ b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/inplanted/InplantedTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.inplanted;
+
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.api.container.Sniffer;
+import org.glassfish.api.admin.*;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.api.embedded.web.EmbeddedWebContainer;
+import org.glassfish.tests.embedded.utils.EmbeddedServerUtils;
+
+import java.io.File;
+import java.util.Enumeration;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Jerome Dochez
+ */
+public class InplantedTest {
+
+    static Server server;
+
+    @BeforeClass
+    public static void setupServer() throws Exception {
+        EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
+        efsb.installRoot(EmbeddedServerUtils.getServerLocation());
+        server = EmbeddedServerUtils.createServer(efsb.build());
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        System.out.println("test web");
+        File f = new File(System.getProperty("basedir"));
+        f = new File(f, "target");
+        f = new File(f, "test-classes");
+        ScatteredArchive.Builder builder = new ScatteredArchive.Builder("hello", f);
+        builder.addClassPath(f.toURI().toURL());
+        builder.resources(f);
+        ScatteredArchive war = builder.buildWar();
+        System.out.println("War content");
+        Enumeration<String> contents = war.entries();
+        while(contents.hasMoreElements()) {
+            System.out.println(contents.nextElement());
+        }
+        Port http = server.createPort(8080);
+        ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
+        server.addContainer(b);
+        EmbeddedWebContainer embedded = (EmbeddedWebContainer) b.create(server);
+        embedded.bind(http, "http");
+        
+        DeployCommandParameters dp = new DeployCommandParameters(f);
+        String appName = server.getDeployer().deploy(war, dp);
+        WebClient webClient = new WebClient();
+        Page page =  webClient.getPage("http://localhost:8080/test-classes/hello");
+        System.out.println("Got response " + page.getWebResponse().getContentAsString());
+        Assert.assertTrue("Servlet returned wrong content", page.getWebResponse().getContentAsString().startsWith("Hello World"));
+        server.getDeployer().undeploy(appName, null);
+    }
+
+    @Test
+    public void Test() {
+
+        ServiceLocator habitat = server.getHabitat();
+        System.out.println("Process type is " + habitat.<ProcessEnvironment>getService(ProcessEnvironment.class).getProcessType());
+        for (Sniffer s : habitat.<Sniffer>getAllServices(Sniffer.class)) {
+            System.out.println("Got sniffer " + s.getModuleType());
+        }
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws Exception {
+        EmbeddedServerUtils.shutdownServer(server);                
+    }
+}
diff --git a/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/web/HelloWeb.java b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/web/HelloWeb.java
new file mode 100644
index 0000000..5b80833
--- /dev/null
+++ b/appserver/tests/embedded/inplanted/src/test/java/org/glassfish/tests/embedded/web/HelloWeb.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+
+@WebServlet(urlPatterns={"/hello"})
+public class HelloWeb extends HttpServlet {
+
+    public HelloWeb() {
+        System.out.println("Servlet WEB-HELLO initialized");
+    }
+   
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+
+        PrintWriter pw = res.getWriter();
+        try {
+			pw.println("Hello World !");
+  		} catch(Exception e) {
+        	e.printStackTrace();
+        }
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/applicationDispatcher/pom.xml b/appserver/tests/embedded/maven-plugin/applicationDispatcher/pom.xml
new file mode 100644
index 0000000..95bae07
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/applicationDispatcher/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>applicationDispatcher</artifactId>
+    <packaging>war</packaging>
+    <name>Application Dispatcher Test (maven-plugin/applicationDispatcher)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..a08b8c0
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/java/test/ServletTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest extends HttpServlet{
+
+    private ServletContext context;
+    private static String status = "ApplicationDispatcher::PASS";
+   
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");
+
+        try{
+            RequestDispatcher requestD = 
+                            getServletContext().getRequestDispatcher("/test.jsp");
+
+            if ( requestD == null){
+                status = "ApplicationDispatcher::FAIL";          
+            }
+            System.out.println("[Servlet.RequestDispatcher: " + requestD + "]");
+        } catch (Throwable t){
+                status = "ApplicationDispatcher::FAIL";          
+        }
+        System.out.println("status: " + status); 
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+
+        PrintWriter out = response.getWriter();
+        response.setContentType("text/html");
+        out.println(status);
+    }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..655c0ca
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+        <load-on-startup>1000</load-on-startup>
+    </servlet>  
+
+   <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>    
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/webapp/test.jsp b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/webapp/test.jsp
new file mode 100644
index 0000000..9c4e305
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/main/webapp/test.jsp
@@ -0,0 +1,19 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<h1> Test </h1>
diff --git a/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/test/java/org/glassfish/tests/applicationDispatcher/WebTest.java b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/test/java/org/glassfish/tests/applicationDispatcher/WebTest.java
new file mode 100644
index 0000000..62a45a2
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/applicationDispatcher/src/test/java/org/glassfish/tests/applicationDispatcher/WebTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.applicationDispatcher;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 1;
+
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "ApplicationDispatcher", contextPath+"/ServletTest");
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            URL servlet = new URL("http://localhost:8080/test");
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            String line = null;
+            int index, lineNum=0;
+            while ((line = in.readLine()) != null) {
+                index = line.indexOf("::");
+                System.out.println(lineNum+": "+line);
+                if (index != -1) {
+                    String status = line.substring(index+2);
+                    if (status.equalsIgnoreCase("PASS")){
+                        count++;
+                    }
+                }
+                lineNum++;
+            }
+            Assert.assertTrue(count==EXPECTED_COUNT);
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/dirListing/pom.xml b/appserver/tests/embedded/maven-plugin/dirListing/pom.xml
new file mode 100644
index 0000000..df4b277
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/dirListing/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>dirListing</artifactId>
+    <packaging>war</packaging>
+    <name>Directory Listing Test (maven-plugin/dirListing)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <configuration>
+                    <goalPrefix>glassfish</goalPrefix>
+                    <app>target/dirListing.war</app>
+                    <port>8080</port>
+                    <name>test</name>
+                    <contextRoot>test</contextRoot>
+                    <serverID>embedded</serverID>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/dirListing/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/dirListing/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..8ab08d2
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/dirListing/src/main/java/test/ServletTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest extends HttpServlet implements HttpSessionListener {
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+    }
+
+
+    public void sessionCreated(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionCreated]");
+    }
+    
+    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionDestroyed]");
+    }
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/dirListing/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/dirListing/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..6f43e08
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/dirListing/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+
+    <listener>     
+        <listener-class>test.ServletTest</listener-class>
+    </listener>
+
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+
+    <servlet>
+        <servlet-name>default</servlet-name>
+        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
+        <init-param>
+            <param-name>debug</param-name>
+            <param-value>0</param-value>
+        </init-param>
+        <init-param>
+            <param-name>listings</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>default</servlet-name>
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+     </servlet-mapping>
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/dirListing/src/test/java/org/glassfish/tests/dirListing/WebTest.java b/appserver/tests/embedded/maven-plugin/dirListing/src/test/java/org/glassfish/tests/dirListing/WebTest.java
new file mode 100644
index 0000000..54ed6e3
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/dirListing/src/test/java/org/glassfish/tests/dirListing/WebTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.dirListing;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 1;
+
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "", contextPath+"/");
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            URL servlet = new URL("http://localhost:8080/test");
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            String line = null;            
+            int index=0, lineNum=0;
+            String cookies = "";
+            while ((line = in.readLine()) != null) {
+                System.out.println(lineNum + ": " + line);
+                if (line.indexOf("Directory Listing") != -1){
+                    System.out.println("Getting a \"Directory Listing\"");
+                    count++;
+                    break;
+                }
+                lineNum++;
+            }
+            Assert.assertTrue(count==EXPECTED_COUNT);
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/filterURIMapping/pom.xml b/appserver/tests/embedded/maven-plugin/filterURIMapping/pom.xml
new file mode 100644
index 0000000..4c50b54
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/filterURIMapping/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>filterURIMapping</artifactId>
+    <packaging>war</packaging>
+    <name>Filter URI Mapping Test (maven-plugin/filterURIMapping)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/java/test/FilterTest.java b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/java/test/FilterTest.java
new file mode 100644
index 0000000..57a5e16
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/java/test/FilterTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+public class FilterTest implements Filter{
+    
+    private ServletContext context;
+    
+    public void destroy() {
+        System.out.println("[Filter.destroy]");
+    }    
+    
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException {
+        System.out.println("[Filter.doFilter]");
+          
+        ((HttpServletRequest)request).getSession().setAttribute("FILTER", "PASS");
+        filterChain.doFilter(request, response);
+        
+    }    
+    
+    
+    public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException {
+        System.out.println("[Filter.init]");
+        context = filterConfig.getServletContext();
+    }
+    
+}
diff --git a/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..ef70056
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/java/test/ServletTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+public class ServletTest extends HttpServlet {
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");        
+        context = config.getServletContext();
+        System.out.println("[Servlet.init] " + context.getMajorVersion());
+        
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+        
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        
+        Object obj = request.getSession().getAttribute("FILTER");
+        System.out.println(obj);
+        if ((obj != null) && (obj.equals("PASS"))) {
+            out.println("Filter invoked");
+        }
+        	
+    }
+
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100755
index 0000000..20414c2
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Servlet 2.3//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_3-0.dtd">
+
+<sun-web-app>
+
+    <security-role-mapping>
+       <role-name>nonuser</role-name>
+       <principal-name>nonuser</principal-name>
+    </security-role-mapping>
+<!--
+    <servlet>
+         <servlet-name>ServletTest</servlet-name>
+         <principal-name>nonuser</principal-name>
+     </servlet>
+-->
+</sun-web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..c9b81fe
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+
+    <filter>
+        <filter-name>FilterTest</filter-name>
+        <filter-class>test.FilterTest</filter-class>
+    </filter>    
+        
+    <filter-mapping>
+        <filter-name>FilterTest</filter-name>
+        <url-pattern>/ServletTest</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+        <dispatcher>FORWARD</dispatcher>  
+        <dispatcher>ERROR</dispatcher> 
+    </filter-mapping>
+
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+    
+    <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+    </servlet-mapping>
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/filterURIMapping/src/test/java/org/glassfish/tests/filterURIMapping/WebTest.java b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/test/java/org/glassfish/tests/filterURIMapping/WebTest.java
new file mode 100644
index 0000000..4f8e44f
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/filterURIMapping/src/test/java/org/glassfish/tests/filterURIMapping/WebTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.sessionDestroyed;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 1;
+
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "DESTROYED", contextPath+"/ServletTest;test=aaa");
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        BufferedReader in = null;
+        boolean pass = false;
+        try {
+            URL servlet = new URL("http://localhost:8080/"+contextPath);
+            URLConnection yc = servlet.openConnection();
+            in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            String line = null;
+            int index;
+            while ((line = in.readLine()) != null) {
+                System.out.println(line);
+                if (line.startsWith("Filter invoked")) {
+                    pass = true;
+                    break;
+                }
+            }
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        } finally {
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ioe) {
+                // ignore
+            }  
+        }
+        Assert.assertTrue(pass);
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/getRequestURI/pom.xml b/appserver/tests/embedded/maven-plugin/getRequestURI/pom.xml
new file mode 100644
index 0000000..9ae6f37
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/getRequestURI/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>getRequestURI</artifactId>
+    <packaging>war</packaging>
+    <name>Get Request URI Test (maven-plugin/getRequestURI)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/java/.gitkeep_empty_dir b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/java/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/java/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100755
index 0000000..99e25ad
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Servlet 2.3//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_3-0.dtd">
+
+<sun-web-app>
+
+</sun-web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..3bcbccd
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+     
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+    
+   <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+    </servlet-mapping>
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/first.jsp b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/first.jsp
new file mode 100644
index 0000000..d37aa17
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/first.jsp
@@ -0,0 +1,44 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ page import="java.util.*" %>
+<%@ page import="java.net.*" %>
+
+<html>
+  <body>
+    <title> First Page </title>
+
+    <%
+      String uri = request.getRequestURI();
+
+      //
+      // cant print it here bcos of the forward - do it in second.jsp
+      //
+      request.setAttribute ("uri_in_first_jsp", uri);
+
+      String url = "/jsp/second.jsp";
+      String value = URLEncoder.encode ("e;fgh@y"); // same as in main.jsp
+
+      url = url + ";iPlanetDirectoryPro=" + value;
+    %>
+
+<jsp:forward page="<%=url%>" />
+
+  </body>
+</html>
+
diff --git a/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/main.jsp b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/main.jsp
new file mode 100644
index 0000000..d192e7b
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/main.jsp
@@ -0,0 +1,38 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ page import="java.util.*" %>
+<%@ page import="java.net.*" %>
+
+<html>
+  <body>
+    <title>Redirecting ... </title>
+
+    <%
+      String url = "/web-getRequestURI/jsp/first.jsp";
+
+      String value = URLEncoder.encode ("e;fgh@y");
+      url = url + ";iPlanetDirectoryPro=" + value;
+
+      response.sendRedirect (url);
+
+    %>
+
+  </body>
+</html>
+
diff --git a/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/second.jsp b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/second.jsp
new file mode 100644
index 0000000..6884545
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/getRequestURI/src/main/webapp/second.jsp
@@ -0,0 +1,44 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ page import="java.util.*" %>
+<%@ page import="java.net.*" %>
+
+<html>
+  <body>
+    <title>Second Page </title>
+
+    <%
+      String thisURI = request.getRequestURI();
+
+      //
+      // retrieve the one set in first.
+      //
+      String firstURI = (String)request.getAttribute ("uri_in_first_jsp");
+
+      request.setAttribute("uri_in_first_jsp", firstURI);
+      request.setAttribute("uri_in_second_jsp", thisURI);
+
+      out.println ("<br/> request.getRequestURI() of first.jsp: " + firstURI);
+      out.println ("<br/> request.getRequestURI() in second.jsp: " + thisURI);
+    %>
+
+
+  </body>
+</html>
+
diff --git a/appserver/tests/embedded/maven-plugin/index/pom.xml b/appserver/tests/embedded/maven-plugin/index/pom.xml
new file mode 100644
index 0000000..79cbd24
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/index/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>index</artifactId>
+    <packaging>pom</packaging>
+    <name>Index Page Test (maven-plugin/index)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/index/src/main/java/.gitkeep_empty_dir b/appserver/tests/embedded/maven-plugin/index/src/main/java/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/index/src/main/java/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/maven-plugin/index/src/test/java/org/glassfish/tests/index/WebTest.java b/appserver/tests/embedded/maven-plugin/index/src/test/java/org/glassfish/tests/index/WebTest.java
new file mode 100644
index 0000000..5484863
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/index/src/test/java/org/glassfish/tests/index/WebTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.index;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        try {
+            URL servlet = new URL("http://localhost:8080");
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+
+            String originalLoc = servlet.toString();
+            System.out.println("\n Invoking url: " + servlet.toString());
+            if (yc instanceof HttpURLConnection) {
+                HttpURLConnection urlConnection = (HttpURLConnection)yc;
+                urlConnection.setDoOutput(true);
+
+                DataOutputStream out =
+                   new DataOutputStream(urlConnection.getOutputStream());
+                                    out.writeByte(1);
+
+               int responseCode=  urlConnection.getResponseCode();
+               System.out.println("Response code: " + responseCode + " Expected code: 200");
+               Assert.assertTrue(urlConnection.getResponseCode()==200);
+            }
+
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/init/pom.xml b/appserver/tests/embedded/maven-plugin/init/pom.xml
new file mode 100644
index 0000000..2ad1bd2
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/init/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>init</artifactId>
+    <packaging>pom</packaging>
+    <name>Bootstrap all tests to use ${project.version} of glassfish-embedded-all</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/pom.xml b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/pom.xml
new file mode 100644
index 0000000..e8dbf56
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>jmxUndeployEvent</artifactId>
+    <packaging>war</packaging>
+    <name>JMX Undeployment Event Test (maven-plugin/jmsUndeploymentTest)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                            <goal>undeploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..1d6e81f
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/main/java/test/ServletTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest extends HttpServlet{
+   
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+        
+        PrintWriter out = response.getWriter();
+        out.println("jmxUndeployEvent::FAIL");
+    }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..6be4073
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+
+   <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+    </servlet-mapping>
+
+    
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/test/java/org/glassfish/tests/jmxUndeployEvent/WebTest.java b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/test/java/org/glassfish/tests/jmxUndeployEvent/WebTest.java
new file mode 100644
index 0000000..609ae0a
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jmxUndeployEvent/src/test/java/org/glassfish/tests/jmxUndeployEvent/WebTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.jmxUndeployEvent;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.HttpURLConnection;
+
+public class WebTest {
+           
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        URL url = new URL("http://localhost:8080/"+contextPath+"/ServletTest");
+        URLConnection conn = url.openConnection();
+        if (conn instanceof HttpURLConnection) {
+            HttpURLConnection urlConnection = (HttpURLConnection)conn;
+            urlConnection.setDoOutput(true);
+            DataOutputStream out =
+                    new DataOutputStream(urlConnection.getOutputStream());
+            out.writeByte(1);
+            int responseCode=  urlConnection.getResponseCode();
+            System.out.println("responseCode: " + responseCode);
+            Assert.assertTrue(urlConnection.getResponseCode()==404);
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/pom.xml b/appserver/tests/embedded/maven-plugin/jsftest/pom.xml
new file mode 100644
index 0000000..209a35e
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>jsftest</artifactId>
+    <packaging>war</packaging>
+    <name>Test JSF (maven-plugin/jsftest)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <configuration>
+                    <ports>
+                        <https-listener>8181</https-listener>
+                    </ports>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.faces</groupId>
+            <artifactId>javax.faces-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/org/glassfish/tests/embedded/jsftest/JSFTestBean.java b/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/org/glassfish/tests/embedded/jsftest/JSFTestBean.java
new file mode 100644
index 0000000..d37232e
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/org/glassfish/tests/embedded/jsftest/JSFTestBean.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.jsftest;
+
+import javax.faces.bean.ManagedBean;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+@ManagedBean(name = "testbean")
+public class JSFTestBean {
+
+    public TestTable[] getTestTable() {
+        return testTable;
+    }
+
+    private TestTable[] testTable = new TestTable[]{
+            new TestTable("BHAVANI", "+91999000000", "INDIA"),
+            new TestTable("SHANKAR", "+199999999999", "USA"),
+            new TestTable("Mr. X", "+122222222", "SFO"),
+    };
+
+    
+    public class TestTable {
+        String name;
+        String number;
+        String country;
+
+        public TestTable(String name, String phone, String country) {
+            this.name = name;
+            this.number = phone;
+            this.country = country;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getNumber() {
+            return number;
+        }
+
+        public String getCountry() {
+            return country;
+        }
+    }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/org/glassfish/tests/embedded/jsftest/JSFTestServlet.java b/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/org/glassfish/tests/embedded/jsftest/JSFTestServlet.java
new file mode 100644
index 0000000..d759242
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/org/glassfish/tests/embedded/jsftest/JSFTestServlet.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.jsftest;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+public class JSFTestServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest request,
+                         HttpServletResponse response) throws ServletException, IOException {
+        FacesContextFactory facesContextFactory =
+                (FacesContextFactory) FactoryFinder.getFactory(
+                        FactoryFinder.FACES_CONTEXT_FACTORY);
+
+        LifecycleFactory lifecycleFactory =
+                (LifecycleFactory) FactoryFinder.getFactory(
+                        FactoryFinder.LIFECYCLE_FACTORY);
+
+        ServletContext context = getServletContext();
+        FacesContext facesContext =
+                facesContextFactory.getFacesContext(context,
+                        request,
+                        response,
+                        lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
+
+        Application application = facesContext.getApplication();
+        ViewHandler viewHandler = application.getViewHandler();
+        UIViewRoot viewRoot = viewHandler.createView(facesContext, null);
+        facesContext.setViewRoot(viewRoot);
+
+        PrintWriter pw = response.getWriter();
+        pw.println("Created viewRoot " + viewRoot);
+        pw.flush();
+        pw.close();
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/test/.gitkeep_empty_dir b/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/test/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/src/main/java/test/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..c9088ac
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
+<sun-web-app error-url="">
+  <context-root>/hellojsf</context-root>
+  <class-loader delegate="true"/>
+  <jsp-config>
+    <property name="keepgenerated" value="true">
+      <description>Keep a copy of the generated servlet class' java code.</description>
+    </property>
+  </jsp-config>
+</sun-web-app>
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..7e35f53
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+    <context-param>
+        <param-name>javax.faces.PROJECT_STAGE</param-name>
+        <param-value>Development</param-value>
+    </context-param>
+    <servlet>
+        <servlet-name>Faces Servlet</servlet-name>
+        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>JSFTestServlet</servlet-name>
+        <servlet-class>org.glassfish.tests.embedded.jsftest.JSFTestServlet</servlet-class>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>Faces Servlet</servlet-name>
+        <url-pattern>/faces/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>JSFTestServlet</servlet-name>
+        <url-pattern>/JSFTestServlet</url-pattern>
+    </servlet-mapping>
+    <session-config>
+        <session-timeout>
+            30
+        </session-timeout>
+    </session-config>
+    <welcome-file-list>
+        <welcome-file>faces/index.xhtml</welcome-file>
+    </welcome-file-list>
+</web-app>
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/index.xhtml b/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/index.xhtml
new file mode 100644
index 0000000..abade3b
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/src/main/webapp/index.xhtml
@@ -0,0 +1,63 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+<h:head>
+    <title>JSF Test</title>
+</h:head>
+<h:body>
+    <f:view>
+        <h:form>
+            <h:dataTable value="#{testbean.testTable}" var="tableEntry">
+                
+                <f:facet name="header">
+                    <h:outputText value="JSF Table"/>
+                </f:facet>
+
+                <h:column>
+                    <f:facet name="header">
+                        <h:outputText value="name"/>
+                    </f:facet>
+                    <h:outputText value="#{tableEntry.name}"></h:outputText>
+                </h:column>
+
+                <h:column>
+                    <f:facet name="header">
+                        <h:outputText value="number"/>
+                    </f:facet>
+                    <h:outputText value="#{tableEntry.number}"></h:outputText>
+                </h:column>
+
+                <h:column>
+                    <f:facet name="header">
+                        <h:outputText value="country"/>
+                    </f:facet>
+                    <h:outputText value="#{tableEntry.country}"></h:outputText>
+                </h:column>
+
+            </h:dataTable>
+        </h:form>
+    </f:view>
+</h:body>
+</html>
+
diff --git a/appserver/tests/embedded/maven-plugin/jsftest/src/test/java/org/glassfish/tests/embedded/jsftest/JSFTest.java b/appserver/tests/embedded/maven-plugin/jsftest/src/test/java/org/glassfish/tests/embedded/jsftest/JSFTest.java
new file mode 100644
index 0000000..79b346a
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsftest/src/test/java/org/glassfish/tests/embedded/jsftest/JSFTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.jsftest;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+
+public class JSFTest {
+
+    @Test
+    public void testWeb() throws Exception {
+
+        disableCertValidation();
+
+        goGet("http://localhost:8080/test/JSFTestServlet", "Created viewRoot");
+        
+        // test non secure access.
+        goGet("http://localhost:8080/test", "BHAVANI", "SHANKAR", "Mr. X");
+
+        // test secure access.
+        goGet("https://localhost:8181/test", "BHAVANI", "SHANKAR", "Mr. X");
+    }
+
+    private static void goGet(String url, String... match) throws Exception {
+        try {
+
+            URL servlet = new URL(url);
+            HttpURLConnection uc = (HttpURLConnection) servlet.openConnection();
+            System.out.println("\nURLConnection = " + uc + " : ");
+            if (uc.getResponseCode() != 200) {
+                throw new Exception("Servlet did not return 200 OK response code");
+            }
+
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    uc.getInputStream()));
+            String line = null;
+            boolean[] found = new boolean[match.length];
+
+            int count = 0;
+            while ((line = in.readLine()) != null) {
+                System.out.println(line);
+                for (String m : match) {
+                    int index = line.indexOf(m);
+                    if (index != -1 && count < match.length) {
+                        found[count++] = true;
+                        System.out.println("Found [" + m + "] in the response, index = " + count);
+                        break;
+                    }
+                }
+            }
+
+            for (boolean f : found) {
+                Assert.assertTrue(f);
+            }
+            System.out.println("\n***** SUCCESS **** Found all matches in the response.*****\n");
+            in.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+    public static void disableCertValidation() {
+        // Create a trust manager that does not validate certificate chains
+        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+            public X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+
+            public void checkClientTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+
+            public void checkServerTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+        }};
+
+        try {
+            SSLContext sc = SSLContext.getInstance("TLS");
+            sc.init(null, trustAllCerts, new SecureRandom());
+            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+        } catch (Exception e) {
+            return;
+        }
+    }
+
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/pom.xml b/appserver/tests/embedded/maven-plugin/jsptest/pom.xml
new file mode 100644
index 0000000..2eaea5f
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>jsptest</artifactId>
+    <packaging>war</packaging>
+    <name>Test web app containing JSPs/JSTLs (maven-plugin/jsptest)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/java/org/glassfish/tests/embedded/jsptest/JspTestServlet.java b/appserver/tests/embedded/maven-plugin/jsptest/src/main/java/org/glassfish/tests/embedded/jsptest/JspTestServlet.java
new file mode 100644
index 0000000..948e28d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/java/org/glassfish/tests/embedded/jsptest/JspTestServlet.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.jsptest;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+@WebServlet(name="JspTestServlet", urlPatterns = "/JspTestServlet")
+public class JspTestServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+
+        print("\n[OUTPUT from JspTestServlet]", out);
+        print("[Hi from JspTestServlet]", out);
+        print("[End of OUTPUT from SecureWebAppTestServlet]", out);
+        
+        out.flush();
+        out.close();
+    }
+
+    private void print(String msg, PrintWriter out) {
+        out.println(msg);
+        System.out.println(msg);
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/java/test/.gitkeep_empty_dir b/appserver/tests/embedded/maven-plugin/jsptest/src/main/java/test/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/java/test/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/resources/LocalStrings.properties b/appserver/tests/embedded/maven-plugin/jsptest/src/main/resources/LocalStrings.properties
new file mode 100644
index 0000000..38bb205
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/resources/LocalStrings.properties
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0, which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# This Source Code may also be made available under the following Secondary
+# Licenses when the conditions for such availability set forth in the
+# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+# version 2 with the GNU Classpath Exception, which is available at
+# https://www.gnu.org/software/classpath/license.html.
+#
+# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+#
+
+greeting_message=Hi, my name is Bhavani. What's yours?
+greeting_response=Hello
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..5187c54
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>/hellojsp</context-root> 
+</sun-web-app>
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..ace5297
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+  <display-name>jsptest</display-name>  
+  <distributable/>
+</web-app>
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/images/duke.waving.gif b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/images/duke.waving.gif
new file mode 100644
index 0000000..4336a2d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/images/duke.waving.gif
Binary files differ
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/index.jsp b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/index.jsp
new file mode 100644
index 0000000..a1b427e
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/index.jsp
@@ -0,0 +1,44 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+
+<html>
+<head><title>Hello</title></head>
+<body bgcolor="white">
+<img src="images/duke.waving.gif"> 
+
+<fmt:requestEncoding value="UTF-8"/>
+
+<fmt:setBundle basename="LocalStrings" var="resourceBundle" scope="page"/>
+
+<h2><fmt:message key="greeting_message" bundle="${resourceBundle}"/></h2>
+<form method="get">
+<input type="text" name="username" size="25">
+<p></p>
+<input type="submit" value="Submit">
+<input type="reset" value="Reset">
+</form>
+
+<c:if test="${not empty param['username']}">
+    <%@include file="response.jsp" %>
+</c:if>
+
+</body>
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/response.jsp b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/response.jsp
new file mode 100644
index 0000000..09a6de7
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/main/webapp/response.jsp
@@ -0,0 +1,50 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+
+<%@ page import="javax.servlet.http.*" %>
+
+<%
+    String user = (String)request.getParameter("username");
+    HttpSession httpSession = request.getSession();
+    String users = (String)httpSession.getAttribute("users");
+    if ( users == null ) {
+	users = user;
+    }
+    else {
+	users = users + ", " + user;
+    }
+    httpSession.setAttribute("users", users);
+%>
+
+
+<h2><font color="black"><fmt:message key="greeting_response" bundle="${resourceBundle}"/>, <%= users %>!</font></h2>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/jsptest/src/test/java/org/glassfish/tests/embedded/jsptest/JspTest.java b/appserver/tests/embedded/maven-plugin/jsptest/src/test/java/org/glassfish/tests/embedded/jsptest/JspTest.java
new file mode 100644
index 0000000..5620662
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/jsptest/src/test/java/org/glassfish/tests/embedded/jsptest/JspTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.jsptest;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+
+public class JspTest {
+
+//    private static int count = 0;
+    private static int EXPECTED_COUNT = 3;
+
+    private String contextPath = "test";
+
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        // test non secure access.
+        goGet("http://localhost:8080/test", "Hi, my name is Bhavani. What's yours?");
+        goGet("http://localhost:8080/test/JspTestServlet", "Hi from JspTestServlet");
+
+        // test secure access
+        goGet("https://localhost:8181/test", "Hi, my name is Bhavani. What's yours?");
+        goGet("https://localhost:8181/test/JspTestServlet", "Hi from JspTestServlet");
+    }
+
+    private static void goGet(String url, String result) throws Exception {
+        try {
+            disableCertValidation();
+            URL servlet = new URL(url);
+            HttpURLConnection uc = (HttpURLConnection)servlet.openConnection();
+            System.out.println("\nURLConnection = " + uc + " : ");
+            if (uc.getResponseCode() != 200) {
+                throw new Exception("Servlet did not return 200 OK response code");
+            }
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    uc.getInputStream()));
+            String line = null;
+            boolean found = false;
+            int index;
+            while ((line = in.readLine()) != null) {
+                System.out.println(line);
+                index = line.indexOf(result);
+                if (index != -1) {
+                    found = true;
+                }
+            }
+            Assert.assertTrue(found);
+            System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+            in.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+    public static void disableCertValidation() {
+        // Create a trust manager that does not validate certificate chains
+        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+            public X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+
+            public void checkClientTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+
+            public void checkServerTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+        }};
+
+        try {
+            SSLContext sc = SSLContext.getInstance("TLS");
+            sc.init(null, trustAllCerts, new SecureRandom());
+            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+        } catch (Exception e) {
+            return;
+        }
+    }
+
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/localejbs/pom.xml b/appserver/tests/embedded/maven-plugin/localejbs/pom.xml
new file mode 100644
index 0000000..ac7c83c
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/localejbs/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>localejbs</artifactId>
+    <packaging>war</packaging>
+    <name>Test local EJBs using maven-plugin</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ejb</groupId>
+            <artifactId>javax.ejb-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/LocalEjbTest.java b/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/LocalEjbTest.java
new file mode 100644
index 0000000..f30b381
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/LocalEjbTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.localejbs;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.naming.InitialContext;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class LocalEjbTest {
+
+    @Test
+    public void testTimer() throws Exception {
+        try {
+            InitialContext ic = new InitialContext();
+            TimerEjb ejb = (TimerEjb) ic.lookup("java:global/localejbs/TimerEjb");
+            System.out.println("Looked up [" + ejb + "]");
+            ejb.createTimer();
+            System.out.println("createTimer called");
+            Thread.sleep(4000);
+            boolean result = ejb.verifyTimer();
+            System.out.println("EJB timer called: " + result);
+            Assert.assertTrue(result);
+            System.err.println("TimerEJB successful.");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/TesterServlet.java b/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/TesterServlet.java
new file mode 100644
index 0000000..b696088
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/TesterServlet.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.localejbs;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.annotation.WebServlet;
+import java.io.IOException;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+@WebServlet(name="TesterServlet", urlPatterns="/TesterServlet")
+public class TesterServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        System.out.println("TesterServlet invoked");
+        Result res = JUnitCore.runClasses(LocalEjbTest.class);
+        if(res.getFailureCount() == 0) {
+            httpServletResponse.setStatus(200, "All tests passed");
+        } else {
+            httpServletResponse.sendError(500, "One or more tests failed");
+        }
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/TimerEjb.java b/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/TimerEjb.java
new file mode 100644
index 0000000..25f6a48
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/localejbs/src/main/java/org/glassfish/tests/embedded/localejbs/TimerEjb.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.localejbs;
+
+import javax.ejb.*;
+import javax.naming.InitialContext;
+
+@Stateless
+public class TimerEjb {
+
+    private static volatile boolean timeoutWasCalled = false;
+    private static volatile boolean autotimeoutWasCalled = false;
+
+    public void createTimer() throws Exception {
+        System.err.println("In SimpleEjb:createTimer()");
+        TimerService timerSvc = (TimerService) new InitialContext().lookup(
+                "java:comp/TimerService");
+        Timer t = timerSvc.createTimer(2, "timer01");
+    }
+
+    public boolean verifyTimer() {
+        return timeoutWasCalled && autotimeoutWasCalled;
+    }
+
+    @Timeout
+    private void timeout(Timer t) {
+        System.err.println("in SimpleEjb: timeout " + t.getInfo());
+        timeoutWasCalled = true;
+    }
+
+    @Schedule(second = "*", minute = "*", hour = "*")
+    public void autotest() {
+        if (!autotimeoutWasCalled) {
+            System.err.println("AUTO-TIMEOUT called!!!");
+        }
+        autotimeoutWasCalled = true;
+    }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/localejbs/src/test/java/org/glassfish/tests/embedded/localejbs/EjbTest.java b/appserver/tests/embedded/maven-plugin/localejbs/src/test/java/org/glassfish/tests/embedded/localejbs/EjbTest.java
new file mode 100644
index 0000000..143fdf5
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/localejbs/src/test/java/org/glassfish/tests/embedded/localejbs/EjbTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.localejbs;
+
+import org.junit.Test;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class EjbTest {
+
+    @Test
+    public void test() throws Exception {
+        URL url = new URL("http://localhost:8080/test/TesterServlet");
+        HttpURLConnection uc = (HttpURLConnection)url.openConnection();
+        System.out.println("Test status : " + uc.getResponseMessage());
+        if(uc.getResponseCode() != 200) {
+            throw new Exception(uc.getResponseMessage());
+        }
+        uc.disconnect();
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/mdb/pom.xml b/appserver/tests/embedded/maven-plugin/mdb/pom.xml
new file mode 100644
index 0000000..98b9db5
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/mdb/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>mdb</artifactId>
+    <packaging>war</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>admin</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>admin</goal>
+                        </goals>
+                        <configuration>
+                            <commands>
+                                <param>create-jms-resource --restype javax.jms.Queue --property imqDestinationName=TestQueue jms/TestQueue</param>
+                                <param>create-jms-resource --restype javax.jms.QueueConnectionFactory jms/TestQueueConnectionFactory</param>
+                            </commands>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>deploy</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.jms</groupId>
+            <artifactId>javax.jms-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ejb</groupId>
+            <artifactId>javax.ejb-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/MessageProcessorBean.java b/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/MessageProcessorBean.java
new file mode 100644
index 0000000..3db92e9
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/MessageProcessorBean.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.mdb;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+@MessageDriven(mappedName = "jms/TestQueue", activationConfig = {
+        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
+        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
+})
+public class MessageProcessorBean implements MessageListener {
+
+    private static Logger logger = Logger.getAnonymousLogger();
+
+    public void onMessage(Message message) {
+        try {
+            String msg = ((TextMessage) message).getText();
+            logger.log(Level.INFO, "Message Received [" + msg + "]");
+            FileOutputStream os = new FileOutputStream(new File(
+                    System.getProperty("java.io.tmpdir"), "embedded_mdb_onmessage.txt"));
+            os.write(msg.getBytes());
+            os.flush();
+            os.close();
+        } catch (Exception ex) {
+            logger.log(Level.WARNING, ex.getMessage(), ex);
+        }
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/TesterServlet.java b/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/TesterServlet.java
new file mode 100644
index 0000000..f5e8975
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/TesterServlet.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.mdb;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.annotation.WebServlet;
+import java.io.IOException;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+@WebServlet(name="TesterServlet", urlPatterns="/TesterServlet")
+public class TesterServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        System.out.println("TesterServlet invoked");
+        Result res = JUnitCore.runClasses(UnitTest.class);
+        if(res.getFailureCount() == 0) {
+            httpServletResponse.setStatus(200, "All tests passed");
+        } else {
+            httpServletResponse.sendError(500, "One or more tests failed");
+        }
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/UnitTest.java b/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/UnitTest.java
new file mode 100644
index 0000000..7e2c975
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/mdb/src/main/java/org/glassfish/tests/embedded/mdb/UnitTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.mdb;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class UnitTest {
+
+    @Test
+    public void testTimer() throws Exception {
+        QueueConnection queueConnection = null;
+        QueueSession queueSession = null;
+        try {
+            InitialContext ic = new InitialContext();
+
+            QueueConnectionFactory qcf = (QueueConnectionFactory)
+                    ic.lookup("jms/TestQueueConnectionFactory");
+            javax.jms.Queue queue = (javax.jms.Queue) ic.lookup("jms/TestQueue");
+
+            queueConnection = qcf.createQueueConnection();
+            queueConnection.start();
+
+            queueSession = queueConnection.createQueueSession(false,
+                    Session.AUTO_ACKNOWLEDGE);
+
+            QueueSender sender = queueSession.createSender(queue);
+
+            String str = "Hi From BHAVANI";
+            TextMessage msg = queueSession.createTextMessage(str);
+            sender.send(msg);
+
+            Thread.sleep(5000);
+
+            byte[] message = new byte[msg.getText().length()];
+
+            File savedFile = new File(System.getProperty("java.io.tmpdir"),
+                    "embedded_mdb_onmessage.txt");
+            FileInputStream is = new FileInputStream(savedFile);
+            is.read(message);
+
+            String savedMsg = new String(message);
+
+            if(!savedMsg.equals(str)) {
+                throw new Exception("Sent message [" + str +
+                        " ] does not match the received message [" + savedMsg + "]");
+            } else {
+                System.out.println("Sent message [" + str +
+                        " ]  matches the received message [" + savedMsg + "]");
+            }
+            savedFile.delete();
+        } finally {
+            try {
+                queueSession.close();
+                queueConnection.close();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/mdb/src/test/java/org/glassfish/tests/embedded/mdb/MyTest.java b/appserver/tests/embedded/maven-plugin/mdb/src/test/java/org/glassfish/tests/embedded/mdb/MyTest.java
new file mode 100644
index 0000000..f5cb9ab
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/mdb/src/test/java/org/glassfish/tests/embedded/mdb/MyTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.mdb;
+
+import org.junit.Test;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class MyTest {
+
+    @Test
+    public void test() throws Exception {
+        URL url = new URL("http://localhost:8080/test/TesterServlet");
+        HttpURLConnection uc = (HttpURLConnection) url.openConnection();
+        System.out.println("Test status : " + uc.getResponseMessage());
+        if (uc.getResponseCode() != 200) {
+            throw new Exception(uc.getResponseMessage());
+        }
+        uc.disconnect();
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/pom.xml b/appserver/tests/embedded/maven-plugin/multipleApps/pom.xml
new file mode 100644
index 0000000..33543f3
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/pom.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>multipleApps</artifactId>
+    <packaging>war</packaging>
+    <name>Multiple application deployment test (maven-plugin/multipleApps)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <!-- Start embedded GlassFish -->
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                        </goals>
+                    </execution>
+                    <!-- Run some admin commands -->
+                    <execution>
+                        <id>admin</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>admin</goal>
+                        </goals>
+                        <configuration>
+                            <commands>
+                                <param>list-applications</param>
+                            </commands>
+                        </configuration>
+                    </execution>
+                    <!-- Perform normal deployment (first application) using plugin level configurations -->
+                    <execution>
+                        <id>deploy</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <!-- Deploy second application (using goal specific configurations) -->
+                    <execution>
+                        <id>deploy2</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>deploy</goal>
+                        </goals>
+                        <configuration>
+                            <app>secondapp/secondapp.war</app>
+                            <contextRoot>secondapp</contextRoot>
+                            <name>secondapp</name>
+                            <deploymentParams>
+                                <param>--verify=true</param>
+                            </deploymentParams>
+                        </configuration>
+                    </execution>
+                    <!-- Undeploy the second application (using goal specific configurations) -->
+                    <execution>
+                        <id>undeploy</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                        </goals>
+                        <configuration>
+                            <name>secondapp</name>
+                        </configuration>
+                    </execution>
+                    <!-- Perform normal undeploy (i.e., first app) using plugin level configurations and stop embedded GlassFish -->
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/secondapp/secondapp.war b/appserver/tests/embedded/maven-plugin/multipleApps/secondapp/secondapp.war
new file mode 100644
index 0000000..e0644e9
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/secondapp/secondapp.war
Binary files differ
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/java/org/glassfish/tests/embedded/jsptest/JspTestServlet.java b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/java/org/glassfish/tests/embedded/jsptest/JspTestServlet.java
new file mode 100644
index 0000000..948e28d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/java/org/glassfish/tests/embedded/jsptest/JspTestServlet.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.jsptest;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+@WebServlet(name="JspTestServlet", urlPatterns = "/JspTestServlet")
+public class JspTestServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+
+        print("\n[OUTPUT from JspTestServlet]", out);
+        print("[Hi from JspTestServlet]", out);
+        print("[End of OUTPUT from SecureWebAppTestServlet]", out);
+        
+        out.flush();
+        out.close();
+    }
+
+    private void print(String msg, PrintWriter out) {
+        out.println(msg);
+        System.out.println(msg);
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/java/test/.gitkeep_empty_dir b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/java/test/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/java/test/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/resources/LocalStrings.properties b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/resources/LocalStrings.properties
new file mode 100644
index 0000000..38bb205
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/resources/LocalStrings.properties
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0, which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# This Source Code may also be made available under the following Secondary
+# Licenses when the conditions for such availability set forth in the
+# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+# version 2 with the GNU Classpath Exception, which is available at
+# https://www.gnu.org/software/classpath/license.html.
+#
+# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+#
+
+greeting_message=Hi, my name is Bhavani. What's yours?
+greeting_response=Hello
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..b43aedf
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>/firstapp</context-root> 
+</sun-web-app>
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..f3f2238
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+  <display-name>firstapp</display-name>  
+  <distributable/>
+</web-app>
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/images/duke.waving.gif b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/images/duke.waving.gif
new file mode 100644
index 0000000..4336a2d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/images/duke.waving.gif
Binary files differ
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/index.jsp b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/index.jsp
new file mode 100644
index 0000000..a1b427e
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/index.jsp
@@ -0,0 +1,44 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+
+<html>
+<head><title>Hello</title></head>
+<body bgcolor="white">
+<img src="images/duke.waving.gif"> 
+
+<fmt:requestEncoding value="UTF-8"/>
+
+<fmt:setBundle basename="LocalStrings" var="resourceBundle" scope="page"/>
+
+<h2><fmt:message key="greeting_message" bundle="${resourceBundle}"/></h2>
+<form method="get">
+<input type="text" name="username" size="25">
+<p></p>
+<input type="submit" value="Submit">
+<input type="reset" value="Reset">
+</form>
+
+<c:if test="${not empty param['username']}">
+    <%@include file="response.jsp" %>
+</c:if>
+
+</body>
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/response.jsp b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/response.jsp
new file mode 100644
index 0000000..09a6de7
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/main/webapp/response.jsp
@@ -0,0 +1,50 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+
+<%@ page import="javax.servlet.http.*" %>
+
+<%
+    String user = (String)request.getParameter("username");
+    HttpSession httpSession = request.getSession();
+    String users = (String)httpSession.getAttribute("users");
+    if ( users == null ) {
+	users = user;
+    }
+    else {
+	users = users + ", " + user;
+    }
+    httpSession.setAttribute("users", users);
+%>
+
+
+<h2><font color="black"><fmt:message key="greeting_response" bundle="${resourceBundle}"/>, <%= users %>!</font></h2>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/multipleApps/src/test/java/org/glassfish/tests/embedded/jsptest/JspTest.java b/appserver/tests/embedded/maven-plugin/multipleApps/src/test/java/org/glassfish/tests/embedded/jsptest/JspTest.java
new file mode 100644
index 0000000..6c09329
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/multipleApps/src/test/java/org/glassfish/tests/embedded/jsptest/JspTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.jsptest;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+
+public class JspTest {
+
+//    private static int count = 0;
+    private static int EXPECTED_COUNT = 3;
+
+    private String contextPath = "test";
+
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        // test non secure access.
+        goGet("http://localhost:8080/test", "Hi, my name is Bhavani. What's yours?");
+        goGet("http://localhost:8080/test/JspTestServlet", "Hi from JspTestServlet");
+
+        // test secure access
+        goGet("https://localhost:8181/test", "Hi, my name is Bhavani. What's yours?");
+        goGet("https://localhost:8181/test/JspTestServlet", "Hi from JspTestServlet");
+
+        // test second app
+        goGet("http://localhost:8080/secondapp", "Hi, my name is Duke. What's yours?");
+        goGet("https://localhost:8181/secondapp", "Hi, my name is Duke. What's yours?");
+    }
+
+    private static void goGet(String url, String result) throws Exception {
+        try {
+            disableCertValidation();
+            URL servlet = new URL(url);
+            HttpURLConnection uc = (HttpURLConnection)servlet.openConnection();
+            System.out.println("\nURLConnection = " + uc + " : ");
+            if (uc.getResponseCode() != 200) {
+                throw new Exception("Servlet did not return 200 OK response code");
+            }
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    uc.getInputStream()));
+            String line = null;
+            boolean found = false;
+            int index;
+            while ((line = in.readLine()) != null) {
+                System.out.println(line);
+                index = line.indexOf(result);
+                if (index != -1) {
+                    found = true;
+                }
+            }
+            Assert.assertTrue(found);
+            System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+            in.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+    public static void disableCertValidation() {
+        // Create a trust manager that does not validate certificate chains
+        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+            public X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+
+            public void checkClientTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+
+            public void checkServerTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+        }};
+
+        try {
+            SSLContext sc = SSLContext.getInstance("TLS");
+            sc.init(null, trustAllCerts, new SecureRandom());
+            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+        } catch (Exception e) {
+            return;
+        }
+    }
+
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/pom.xml b/appserver/tests/embedded/maven-plugin/pom.xml
new file mode 100644
index 0000000..6c15016
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/pom.xml
@@ -0,0 +1,254 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>maven-plugin</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>GlassFish Embedded Maven Plugin Tests</name>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <profiles>
+        <profile>
+            <id>run-with-promoted-builds</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <modules>
+                <module>applicationDispatcher</module>
+                <module>dirListing</module>
+                <module>filterURIMapping</module>
+                <module>getRequestURI</module>
+                <module>index</module>
+                <module>jmxUndeployEvent</module>
+                <module>queryString</module>
+                <!--module>scattered</module-->
+                <module>sessionDestroyed</module>
+                <module>standalonewar</module>
+                <module>websockets</module>
+                <module>webservice</module>
+                <module>secureWebApp</module>
+                <module>jsptest</module>
+                <module>jsftest</module>
+                <module>localejbs</module>
+                <module>multipleApps</module>
+            </modules>
+        </profile>
+        <profile>
+            <id>run-with-snapshot-builds</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>snapshot</value>
+                </property>
+            </activation>
+            <modules>
+                <module>init</module>
+                <module>applicationDispatcher</module>
+                <module>dirListing</module>
+                <module>filterURIMapping</module>
+                <module>getRequestURI</module>
+                <module>index</module>
+                <module>jmxUndeployEvent</module>
+                <module>queryString</module>
+                <module>sessionDestroyed</module>
+                <module>standalonewar</module>
+                <module>websockets</module>
+                <module>webservice</module>
+                <module>secureWebApp</module>
+                <module>jsptest</module>
+                <module>jsftest</module>
+                <module>localejbs</module>
+                <module>multipleApps</module>
+            </modules>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <modules>
+                <module>static-shell-init</module>
+                <module>applicationDispatcher</module>
+                <module>dirListing</module>
+                <module>filterURIMapping</module>
+                <module>getRequestURI</module>
+                <module>index</module>
+                <module>jmxUndeployEvent</module>
+                <module>queryString</module>
+                <module>sessionDestroyed</module>
+                <module>standalonewar</module>
+                <module>websockets</module>
+                <module>webservice</module>
+                <module>secureWebApp</module>
+                <module>jsptest</module>
+                <module>jsftest</module>
+                <module>localejbs</module>
+                <module>multipleApps</module>
+            </modules>
+        </profile>
+    </profiles>
+    
+    
+    <build>
+        <defaultGoal>install</defaultGoal>
+        <testSourceDirectory>src/test/java</testSourceDirectory>
+        <finalName>${project.artifactId}</finalName>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>2.12</version>
+                    <configuration>
+                        <skip>true</skip>
+                        <forkMode>never</forkMode>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <phase>integration-test</phase>
+                            <goals>
+                                <goal>test</goal>
+                            </goals>
+                            <configuration>
+                                <skip>false</skip>
+                                <forkMode>never</forkMode>
+                                <additionalClasspathElements>
+                                    <additionalClasspathElement>target/classes</additionalClasspathElement>
+                                </additionalClasspathElements>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>2.5.1</version>
+                    <configuration>
+                        <source>1.6</source>
+                        <target>1.6</target>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-war-plugin</artifactId>
+                    <version>2.3</version>
+                    <configuration>
+                        <failOnMissingWebXml>false</failOnMissingWebXml>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.glassfish.embedded</groupId>
+                    <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                    <version>5.0</version>
+                    <configuration>
+                        <goalPrefix>glassfish</goalPrefix>
+                        <app>target/${project.artifactId}.war</app>
+                        <port>8080</port>
+                        <name>${project.artifactId}</name>
+                        <contextRoot>test</contextRoot>
+                        <serverID>embedded</serverID>
+                        <ports>
+                            <https-listener>8181</https-listener>
+                        </ports>       
+                    </configuration>
+                    <dependencies>
+                        <dependency>
+                            <groupId>org.glassfish.main.common</groupId>
+                            <artifactId>simple-glassfish-api</artifactId>
+                            <version>${project.version}</version>
+                        </dependency>                    
+                        <dependency>
+                            <groupId>org.glassfish.main.extras</groupId>
+                            <artifactId>glassfish-embedded-all</artifactId>
+                            <version>${project.version}</version>
+                        </dependency>
+                    </dependencies>
+                </plugin>                                    
+            </plugins>
+        </pluginManagement>
+    </build>
+    
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.maven</groupId>
+                <artifactId>maven-plugin-api</artifactId>
+                <version>3.3.9</version>
+            </dependency>
+            <dependency>
+                <groupId>javax.servlet</groupId>
+                <artifactId>javax.servlet-api</artifactId>
+                <version>4.0.0</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>4.12</version>
+            </dependency>
+            <dependency>
+                <groupId>javax.faces</groupId>
+                <artifactId>javax.faces-api</artifactId>
+                <version>2.3</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>javax.ejb</groupId>
+                <artifactId>javax.ejb-api</artifactId>
+                <version>3.2.2</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.glassfish.main.extras</groupId>
+                <artifactId>glassfish-embedded-all</artifactId>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.glassfish.grizzly</groupId>
+                <artifactId>grizzly-websockets</artifactId>
+                <version>2.1</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.glassfish.grizzly</groupId>
+                <artifactId>grizzly-http-servlet</artifactId>
+                <version>2.4.3</version>
+                <scope>provided</scope>
+            </dependency>                    
+            <dependency>
+                <groupId>javax.jms</groupId>
+                <artifactId>javax.jms-api</artifactId>
+                <scope>provided</scope>
+                <version>2.0.1</version>
+            </dependency>                    
+        </dependencies>
+    </dependencyManagement>
+</project>
diff --git a/appserver/tests/embedded/maven-plugin/queryString/pom.xml b/appserver/tests/embedded/maven-plugin/queryString/pom.xml
new file mode 100644
index 0000000..b4e8bb6
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/queryString/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>queryString</artifactId>
+    <packaging>war</packaging>
+    <name>Query String Test (maven-plugin/queryString)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/queryString/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/queryString/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..b006ceb
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/queryString/src/main/java/test/ServletTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+public class ServletTest extends HttpServlet {
+    private static boolean isRedirected = false;
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");        
+        context = config.getServletContext();
+        System.out.println("[Servlet.init] " + context.getMajorVersion());
+        
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+        
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+
+        System.out.println("requestUri: " + request.getRequestURI());
+       
+        if (!isRedirected){
+            String url = request.getParameter("url") + "?TEST=PASS";
+            System.out.println("[URL] " + url);
+            response.sendRedirect(url);
+            isRedirected = true;
+            out.println("TEST:FAIL");
+            out.flush();
+            return;
+        }
+       
+        out.println("TEST:" + request.getParameter("TEST"));
+        out.flush();
+    }
+
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/queryString/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/queryString/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..3dff9cb
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/queryString/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+     
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+    
+   <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+    </servlet-mapping>
+    
+    <session-config>
+        <session-timeout>10</session-timeout>
+    </session-config>
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/queryString/src/test/java/org/glassfish/tests/queryString/WebTest.java b/appserver/tests/embedded/maven-plugin/queryString/src/test/java/org/glassfish/tests/queryString/WebTest.java
new file mode 100644
index 0000000..5442de2
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/queryString/src/test/java/org/glassfish/tests/queryString/WebTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.queryString;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 1;
+
+    private String contextPath = "/test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "TEST", contextPath+"/ServletTest");
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            contextPath += "?url=" + contextPath;
+            System.out.println("Connecting "+contextPath);
+            URL servlet = new URL("http://localhost:8080/"+contextPath);
+            //URL servlet = new URL("http://localhost:8080/test/ServletTest?TEST=PASS");
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            
+            String line = null;
+            int index;
+            while ((line = in.readLine()) != null) {
+                index = line.indexOf(result);
+                System.out.println("[Server response]" + line);
+
+                int pos = line.indexOf("Location");
+                if (pos != -1){
+                   contextPath = line.substring(pos + "Location:".length()).trim();
+                   in.close();
+                   break;
+                }
+            }
+
+            servlet = new URL("http://localhost:8080/"+contextPath);
+            yc = servlet.openConnection();
+            in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+            while ((line = in.readLine()) != null) {
+                index = line.indexOf(result);
+                System.out.println("[Redirect response]" + line);
+
+                if (index != -1) {
+                    index = line.indexOf(":");
+                    String status = line.substring(index+1);
+
+                    if (status.equalsIgnoreCase("PASS")){
+                        count++;
+                    } else {
+                        break;
+                    }
+                }
+            }
+            
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/remoteejbs/pom.xml b/appserver/tests/embedded/maven-plugin/remoteejbs/pom.xml
new file mode 100644
index 0000000..8730baf
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/remoteejbs/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>remoteejbs</artifactId>
+    <packaging>war</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ejb</groupId>
+            <artifactId>javax.ejb-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/remoteejbs/src/main/java/org/glassfish/tests/embedded/remoteejbs/TimerEjb.java b/appserver/tests/embedded/maven-plugin/remoteejbs/src/main/java/org/glassfish/tests/embedded/remoteejbs/TimerEjb.java
new file mode 100644
index 0000000..0a19b3a
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/remoteejbs/src/main/java/org/glassfish/tests/embedded/remoteejbs/TimerEjb.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.remoteejbs;
+
+import javax.ejb.*;
+import javax.naming.InitialContext;
+
+@Stateless
+public class TimerEjb implements TimerRemote {
+
+    private static volatile boolean timeoutWasCalled = false;
+    private static volatile boolean autotimeoutWasCalled = false;
+
+    public void createTimer() throws Exception {
+        System.err.println("In SimpleEjb:createTimer()");
+        TimerService timerSvc = (TimerService) new InitialContext().lookup(
+                "java:comp/TimerService");
+        Timer t = timerSvc.createTimer(2, "timer01");
+    }
+
+    public boolean verifyTimer() {
+        return timeoutWasCalled && autotimeoutWasCalled;
+    }
+
+    @Timeout
+    private void timeout(Timer t) {
+        System.err.println("in SimpleEjb: timeout " + t.getInfo());
+        timeoutWasCalled = true;
+    }
+
+    @Schedule(second = "*", minute = "*", hour = "*")
+    public void autotest() {
+        if (!autotimeoutWasCalled) {
+            System.err.println("AUTO-TIMEOUT called!!!");
+        }
+        autotimeoutWasCalled = true;
+    }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/remoteejbs/src/main/java/org/glassfish/tests/embedded/remoteejbs/TimerRemote.java b/appserver/tests/embedded/maven-plugin/remoteejbs/src/main/java/org/glassfish/tests/embedded/remoteejbs/TimerRemote.java
new file mode 100644
index 0000000..a3c33f8
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/remoteejbs/src/main/java/org/glassfish/tests/embedded/remoteejbs/TimerRemote.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.remoteejbs;
+
+import javax.ejb.Remote;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+@Remote
+public interface TimerRemote {
+
+    void createTimer() throws Exception;
+
+    boolean verifyTimer() throws Exception;
+}
diff --git a/appserver/tests/embedded/maven-plugin/remoteejbs/src/test/java/org/glassfish/tests/embedded/remoteejbs/EjbTest.java b/appserver/tests/embedded/maven-plugin/remoteejbs/src/test/java/org/glassfish/tests/embedded/remoteejbs/EjbTest.java
new file mode 100644
index 0000000..13580be
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/remoteejbs/src/test/java/org/glassfish/tests/embedded/remoteejbs/EjbTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.remoteejbs;
+
+import org.glassfish.tests.embedded.remoteejbs.*;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.naming.InitialContext;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class EjbTest {
+
+    @Test
+    public void testTimer() throws Exception {
+        try {
+            InitialContext ic = new InitialContext();
+            TimerRemote ejb = 
+                    (TimerRemote) ic.lookup("java:global/remoteejbs/TimerEjb");
+            System.out.println("Looked up [" + ejb + "]");
+            ejb.createTimer();
+            System.out.println("createTimer called");
+            Thread.sleep(4000);
+            boolean result = ejb.verifyTimer();
+            System.out.println("EJB timer called: " + result);
+            Assert.assertTrue(result);
+            System.err.println("TimerEJB successful.");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/scattered/pom.xml b/appserver/tests/embedded/maven-plugin/scattered/pom.xml
new file mode 100644
index 0000000..b2c2d88
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish</groupId>
+    <artifactId>scattered</artifactId>
+    <packaging>pom</packaging>
+
+    <name>Maven deploy test</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <configuration>
+                    <rootdirectory>src/main/web</rootdirectory>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>install</phase>
+                        <goals>
+                            <goal>runscatteredarchive</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/FilterTest.java b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/FilterTest.java
new file mode 100755
index 0000000..57a5e16
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/FilterTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+public class FilterTest implements Filter{
+    
+    private ServletContext context;
+    
+    public void destroy() {
+        System.out.println("[Filter.destroy]");
+    }    
+    
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException {
+        System.out.println("[Filter.doFilter]");
+          
+        ((HttpServletRequest)request).getSession().setAttribute("FILTER", "PASS");
+        filterChain.doFilter(request, response);
+        
+    }    
+    
+    
+    public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException {
+        System.out.println("[Filter.init]");
+        context = filterConfig.getServletContext();
+    }
+    
+}
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..9fe46d3
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.xml.sax.InputSource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+// jaxp 1.0.1 imports
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest extends HttpServlet implements HttpSessionListener {
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");        
+        context = config.getServletContext();
+        System.out.println("[Servlet.init] " + context.getMajorVersion());
+        
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+        
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        
+        request.getSession().setAttribute("FILTER-REQUEST", request.getSession().getAttribute("FILTER"));
+        request.getSession().setAttribute("FILTER", "FAIL");        
+        	
+        RequestDispatcher rd = context.getRequestDispatcher("/ServletTest2");
+        rd.forward(request, response);       
+    }
+
+    public void sessionCreated(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionCreated]");
+    }
+    
+    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionDestroyed]");
+        System.out.println("Attributes: " + httpSessionEvent.getSession().getAttribute("test"));
+    }
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest2.java b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest2.java
new file mode 100755
index 0000000..f517cce
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest2.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+public class ServletTest2 extends HttpServlet implements HttpSessionListener {
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet2.init]");        
+        context = config.getServletContext();
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet2.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet2.doPost]");
+      
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        
+        request.getSession().setAttribute("FILTER-FORWARD",request.getSession().getAttribute("FILTER"));
+        request.getSession().setAttribute("FILTER", "FAIL");        
+        
+        RequestDispatcher rd = request.getRequestDispatcher("/ServletTest3");
+        rd.include(request, response);     
+    }
+ 
+    public void sessionCreated(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionCreated]");
+    }
+    
+    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionDestroyed]");
+        System.out.println("Attributes: " + httpSessionEvent.getSession().getAttribute("test"));
+    }
+
+}
+
+
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest3.java b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest3.java
new file mode 100644
index 0000000..4b9b240
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/java/test/ServletTest3.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.xml.sax.InputSource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+// jaxp 1.0.1 imports
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest3 extends HttpServlet{
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet3.init]");        
+        context = config.getServletContext();     
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet3.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet3.doPost]");
+        
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        
+        out.println("FILTER-REQUEST:" + request.getSession().getAttribute("FILTER-REQUEST"));
+        out.println("FILTER-FORWARD:" + request.getSession().getAttribute("FILTER-FORWARD"));
+        out.println("FILTER-INCLUDE:" + request.getSession().getAttribute("FILTER"));
+    }
+
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..fd6410d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Servlet 2.3//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_3-0.dtd">
+
+<sun-web-app>
+<description>tomcat-test</description>
+
+<security-role-mapping>
+   <role-name>tomcat</role-name>
+   <principal-name>tomcat</principal-name>
+   <group-name>tomcat</group-name>
+</security-role-mapping>
+
+</sun-web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..f9861df
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+     
+    <filter>
+        <filter-name>FilterTest</filter-name>
+        <filter-class>test.FilterTest</filter-class>
+    </filter>    
+        
+    <filter-mapping>
+        <filter-name>FilterTest</filter-name>
+        <url-pattern>/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+        <dispatcher>FORWARD</dispatcher>  
+        <dispatcher>ERROR</dispatcher> 
+    </filter-mapping>
+    
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+    <servlet>
+        <display-name>ServletTest2</display-name>
+        <servlet-name>ServletTest2</servlet-name>
+        <servlet-class>test.ServletTest2</servlet-class>
+    </servlet>  
+    <servlet>
+        <display-name>ServletTest3</display-name>
+        <servlet-name>ServletTest3</servlet-name>
+        <servlet-class>test.ServletTest3</servlet-class>
+    </servlet>  
+    
+   <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+    </servlet-mapping>
+   <servlet-mapping>
+        <servlet-name>ServletTest2</servlet-name>
+        <url-pattern>/ServletTest2</url-pattern>
+    </servlet-mapping>
+   <servlet-mapping>
+        <servlet-name>ServletTest3</servlet-name>
+        <url-pattern>/ServletTest3</url-pattern>
+    </servlet-mapping>
+    
+    <session-config>
+        <session-timeout>10</session-timeout>
+    </session-config>
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/index.html b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/index.html
new file mode 100755
index 0000000..ab4b311
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/index.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+Hello World!
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/index.jsp b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/index.jsp
new file mode 100644
index 0000000..c52acd1
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/scattered/src/main/webapp/index.jsp
@@ -0,0 +1,24 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<html>
+  <head/>
+  <body>
+    <p><% out.print("Hello World!"); %></p>
+  </body>
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/secureWebApp/bootstrap.properties b/appserver/tests/embedded/maven-plugin/secureWebApp/bootstrap.properties
new file mode 100644
index 0000000..ba428f1
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/secureWebApp/bootstrap.properties
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0, which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# This Source Code may also be made available under the following Secondary
+# Licenses when the conditions for such availability set forth in the
+# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+# version 2 with the GNU Classpath Exception, which is available at
+# https://www.gnu.org/software/classpath/license.html.
+#
+# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+#
+
+test_key2=test_value_2
diff --git a/appserver/tests/embedded/maven-plugin/secureWebApp/glassfish.properties b/appserver/tests/embedded/maven-plugin/secureWebApp/glassfish.properties
new file mode 100644
index 0000000..70464dc
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/secureWebApp/glassfish.properties
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0, which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# This Source Code may also be made available under the following Secondary
+# Licenses when the conditions for such availability set forth in the
+# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+# version 2 with the GNU Classpath Exception, which is available at
+# https://www.gnu.org/software/classpath/license.html.
+#
+# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+#
+
+embedded-glassfish-config.server.jms-service.jms-host.default_JMS_host.host=0.0.0.0
diff --git a/appserver/tests/embedded/maven-plugin/secureWebApp/pom.xml b/appserver/tests/embedded/maven-plugin/secureWebApp/pom.xml
new file mode 100644
index 0000000..c633ec1
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/secureWebApp/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>securewebapp</artifactId>
+    <packaging>war</packaging>
+    <name>Test https and other plugin configurations (maven-plugin/secureWebApp)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <configuration>
+		    <bootstrapProperties>
+			<property>test_key=test_value</property>
+		    </bootstrapProperties>
+		    <bootstrapPropertiesFile>bootstrap.properties</bootstrapPropertiesFile>
+		    <glassfishProperties>
+			<property>embedded-glassfish-config.server.jms-service.jms-host.default_JMS_host.port=17676</property>
+		    </glassfishProperties>
+		    <glassfishPropertiesFile>glassfish.properties</glassfishPropertiesFile>
+		    <systemProperties>
+			<property>ANTLR_USE_DIRECT_CLASS_LOADING=true</property>
+		    </systemProperties>
+		    <systemPropertiesFile>system.properties</systemPropertiesFile>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ejb</groupId>
+            <artifactId>javax.ejb-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/secureWebApp/src/main/java/test/SecureWebAppTestServlet.java b/appserver/tests/embedded/maven-plugin/secureWebApp/src/main/java/test/SecureWebAppTestServlet.java
new file mode 100644
index 0000000..f204804
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/secureWebApp/src/main/java/test/SecureWebAppTestServlet.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+@WebServlet(name="SecureWebAppTestServlet", urlPatterns = "/SecureWebAppTestServlet")
+public class SecureWebAppTestServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+
+        print("\n[OUTPUT from SecureWebAppTestServlet]", out);
+        print("[Hi from SecureWebAppTestServlet]", out);
+
+        String sysProp = System.getProperty("org.glassfish.embedded.greeting");
+        print("[System property org.glassfish.embedded.greeting = " + sysProp + "]", out);
+        if(!"Hi from BHAVANI".equals(sysProp)) {
+            httpServletResponse.sendError(500,
+                    "System property org.glassfish.embedded.greeting not found");
+            return;
+        }
+
+        Boolean directClassLoading = Boolean.getBoolean("ANTLR_USE_DIRECT_CLASS_LOADING");
+        print("[System property ANTLR_USE_DIRECT_CLASS_LOADING = " +
+                System.getProperty("ANTLR_USE_DIRECT_CLASS_LOADING") + "]", out);
+        if(!directClassLoading) {
+            httpServletResponse.sendError(500,
+                    "System property ANTLR_USE_DIRECT_CLASS_LOADING is not set");
+            return;
+        }
+        print("[End of OUTPUT from SecureWebAppTestServlet]", out);
+        
+        out.flush();
+        out.close();
+    }
+
+    private void print(String msg, PrintWriter out) {
+        out.println(msg);
+        System.out.println(msg);
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/secureWebApp/src/test/java/org/glassfish/tests/embedded/securewebapp/SecureWebAppTest.java b/appserver/tests/embedded/maven-plugin/secureWebApp/src/test/java/org/glassfish/tests/embedded/securewebapp/SecureWebAppTest.java
new file mode 100644
index 0000000..39945fd
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/secureWebApp/src/test/java/org/glassfish/tests/embedded/securewebapp/SecureWebAppTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.securewebapp;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+
+public class SecureWebAppTest {
+
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 3;
+
+    private String contextPath = "test";
+
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "Hi from SecureWebAppTestServlet", contextPath);
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            disableCertValidation();
+            URL servlet = new URL("https://localhost:8181/test/SecureWebAppTestServlet");
+            HttpsURLConnection uc = (HttpsURLConnection) servlet.openConnection();
+            System.out.println("URLConnection = " + uc);
+            if (uc.getResponseCode() != 200) {
+                throw new Exception("Servlet did not return 200 OK response code");
+            }
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    uc.getInputStream()));
+            String line = null;
+            int index;
+            while ((line = in.readLine()) != null) {
+                System.out.println(line);
+                index = line.indexOf(result);
+                if (index != -1) {
+                    index = line.indexOf(":");
+                    String status = line.substring(index + 1);
+
+                    if (status.equalsIgnoreCase("PASS")) {
+                        count++;
+                    } else {
+                        return;
+                    }
+                }
+            }
+            Assert.assertTrue(count == 3);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+    public static void disableCertValidation() {
+        // Create a trust manager that does not validate certificate chains
+        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+            public X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+
+            public void checkClientTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+
+            public void checkServerTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+        }};
+
+        try {
+            SSLContext sc = SSLContext.getInstance("TLS");
+            sc.init(null, trustAllCerts, new SecureRandom());
+            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+        } catch (Exception e) {
+            return;
+        }
+    }
+
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/secureWebApp/system.properties b/appserver/tests/embedded/maven-plugin/secureWebApp/system.properties
new file mode 100644
index 0000000..c5db83a
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/secureWebApp/system.properties
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0, which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# This Source Code may also be made available under the following Secondary
+# Licenses when the conditions for such availability set forth in the
+# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+# version 2 with the GNU Classpath Exception, which is available at
+# https://www.gnu.org/software/classpath/license.html.
+#
+# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+#
+
+org.glassfish.embedded.greeting=Hi from BHAVANI
diff --git a/appserver/tests/embedded/maven-plugin/sessionDestroyed/pom.xml b/appserver/tests/embedded/maven-plugin/sessionDestroyed/pom.xml
new file mode 100644
index 0000000..290fc9c
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/sessionDestroyed/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>sessionDestroyed</artifactId>
+    <packaging>war</packaging>
+    <name>Session Lifecyle Test (maven-plugin/sessionDestroyed)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..0edf37d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/main/java/test/ServletTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest extends HttpServlet implements HttpSessionListener {
+
+    private ServletContext context;
+    private static String status = "DESTROYED:FAIL";
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+
+        request.getSession().setAttribute("test","DESTROYED:PASS");
+        request.getSession().invalidate();
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+
+        out.println(status);
+    }
+
+
+    public void sessionCreated(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionCreated]");
+    }
+    
+    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionDestroyed]");
+        status = (String)httpSessionEvent.getSession().getAttribute("test"); 
+    }
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..7eb5ec0
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+
+    <listener>     
+        <listener-class>test.ServletTest</listener-class>
+    </listener>
+
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+
+   <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+    </servlet-mapping>
+
+    
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/test/java/org/glassfish/tests/sessionDestroyed/WebTest.java b/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/test/java/org/glassfish/tests/sessionDestroyed/WebTest.java
new file mode 100644
index 0000000..9575629
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/sessionDestroyed/src/test/java/org/glassfish/tests/sessionDestroyed/WebTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.sessionDestroyed;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 1;
+
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "DESTROYED", contextPath+"/ServletTest");
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            URL servlet = new URL("http://localhost:8080/"+contextPath);
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            String line = null;
+            int index;
+            while ((line = in.readLine()) != null) {
+                index = line.indexOf(result);
+                System.out.println(line);
+                if (index != -1) {
+                    index = line.indexOf(":");
+                    String status = line.substring(index+1);
+
+                    if (status.equalsIgnoreCase("PASS")){
+                        count++;
+                    } else {
+                        return;
+                    }
+                }
+            }
+            Assert.assertTrue(count==EXPECTED_COUNT);
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/simple/hello.war b/appserver/tests/embedded/maven-plugin/simple/hello.war
new file mode 100644
index 0000000..e57c5c0
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/simple/hello.war
Binary files differ
diff --git a/appserver/tests/embedded/maven-plugin/simple/pom.xml b/appserver/tests/embedded/maven-plugin/simple/pom.xml
new file mode 100644
index 0000000..2a01088
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/simple/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>    
+    <groupId>org.glassfish</groupId>
+    <artifactId>maven-glassfish-plugin-tester-deploy</artifactId>
+    <packaging>pom</packaging>
+    <name>Maven deploy test</name>
+
+    <build>
+        <defaultGoal>install</defaultGoal>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <configuration>
+                    <goalPrefix>glassfish</goalPrefix>
+                    <app>hello.war</app>
+                    <port>8080</port>  
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>install</phase>
+                        <goals>
+                            <goal>start</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/pom.xml b/appserver/tests/embedded/maven-plugin/standalonewar/pom.xml
new file mode 100644
index 0000000..6faeaf9
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>standalonewar</artifactId>
+    <packaging>war</packaging>
+    <name>Standalone WAR Test (maven-plugin/standalonewar)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/FilterTest.java b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/FilterTest.java
new file mode 100755
index 0000000..57a5e16
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/FilterTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+public class FilterTest implements Filter{
+    
+    private ServletContext context;
+    
+    public void destroy() {
+        System.out.println("[Filter.destroy]");
+    }    
+    
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException {
+        System.out.println("[Filter.doFilter]");
+          
+        ((HttpServletRequest)request).getSession().setAttribute("FILTER", "PASS");
+        filterChain.doFilter(request, response);
+        
+    }    
+    
+    
+    public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException {
+        System.out.println("[Filter.init]");
+        context = filterConfig.getServletContext();
+    }
+    
+}
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest.java b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest.java
new file mode 100644
index 0000000..9fe46d3
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.xml.sax.InputSource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+// jaxp 1.0.1 imports
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest extends HttpServlet implements HttpSessionListener {
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet.init]");        
+        context = config.getServletContext();
+        System.out.println("[Servlet.init] " + context.getMajorVersion());
+        
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet.doPost]");
+        
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        
+        request.getSession().setAttribute("FILTER-REQUEST", request.getSession().getAttribute("FILTER"));
+        request.getSession().setAttribute("FILTER", "FAIL");        
+        	
+        RequestDispatcher rd = context.getRequestDispatcher("/ServletTest2");
+        rd.forward(request, response);       
+    }
+
+    public void sessionCreated(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionCreated]");
+    }
+    
+    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionDestroyed]");
+        System.out.println("Attributes: " + httpSessionEvent.getSession().getAttribute("test"));
+    }
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest2.java b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest2.java
new file mode 100755
index 0000000..f517cce
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest2.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+public class ServletTest2 extends HttpServlet implements HttpSessionListener {
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet2.init]");        
+        context = config.getServletContext();
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet2.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet2.doPost]");
+      
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        
+        request.getSession().setAttribute("FILTER-FORWARD",request.getSession().getAttribute("FILTER"));
+        request.getSession().setAttribute("FILTER", "FAIL");        
+        
+        RequestDispatcher rd = request.getRequestDispatcher("/ServletTest3");
+        rd.include(request, response);     
+    }
+ 
+    public void sessionCreated(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionCreated]");
+    }
+    
+    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent httpSessionEvent) {
+        System.out.println("[Servlet.sessionDestroyed]");
+        System.out.println("Attributes: " + httpSessionEvent.getSession().getAttribute("test"));
+    }
+
+}
+
+
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest3.java b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest3.java
new file mode 100644
index 0000000..4b9b240
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/java/test/ServletTest3.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.xml.sax.InputSource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+// jaxp 1.0.1 imports
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.naming.*;
+import javax.sql.*;
+import java.sql.*;
+
+public class ServletTest3 extends HttpServlet{
+
+    private ServletContext context;
+    
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        System.out.println("[Servlet3.init]");        
+        context = config.getServletContext();     
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        System.out.println("[Servlet3.doGet]");
+        doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        
+        System.out.println("[Servlet3.doPost]");
+        
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        
+        out.println("FILTER-REQUEST:" + request.getSession().getAttribute("FILTER-REQUEST"));
+        out.println("FILTER-FORWARD:" + request.getSession().getAttribute("FILTER-FORWARD"));
+        out.println("FILTER-INCLUDE:" + request.getSession().getAttribute("FILTER"));
+    }
+
+}
+
+
+
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..fd6410d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 Servlet 2.3//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_3-0.dtd">
+
+<sun-web-app>
+<description>tomcat-test</description>
+
+<security-role-mapping>
+   <role-name>tomcat</role-name>
+   <principal-name>tomcat</principal-name>
+   <group-name>tomcat</group-name>
+</security-role-mapping>
+
+</sun-web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..f9861df
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+     
+    <filter>
+        <filter-name>FilterTest</filter-name>
+        <filter-class>test.FilterTest</filter-class>
+    </filter>    
+        
+    <filter-mapping>
+        <filter-name>FilterTest</filter-name>
+        <url-pattern>/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+        <dispatcher>FORWARD</dispatcher>  
+        <dispatcher>ERROR</dispatcher> 
+    </filter-mapping>
+    
+    <servlet>
+        <display-name>ServletTest</display-name>
+        <servlet-name>ServletTest</servlet-name>
+        <servlet-class>test.ServletTest</servlet-class>
+    </servlet>  
+    <servlet>
+        <display-name>ServletTest2</display-name>
+        <servlet-name>ServletTest2</servlet-name>
+        <servlet-class>test.ServletTest2</servlet-class>
+    </servlet>  
+    <servlet>
+        <display-name>ServletTest3</display-name>
+        <servlet-name>ServletTest3</servlet-name>
+        <servlet-class>test.ServletTest3</servlet-class>
+    </servlet>  
+    
+   <servlet-mapping>
+        <servlet-name>ServletTest</servlet-name>
+        <url-pattern>/ServletTest</url-pattern>
+    </servlet-mapping>
+   <servlet-mapping>
+        <servlet-name>ServletTest2</servlet-name>
+        <url-pattern>/ServletTest2</url-pattern>
+    </servlet-mapping>
+   <servlet-mapping>
+        <servlet-name>ServletTest3</servlet-name>
+        <url-pattern>/ServletTest3</url-pattern>
+    </servlet-mapping>
+    
+    <session-config>
+        <session-timeout>10</session-timeout>
+    </session-config>
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/index.html b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/index.html
new file mode 100755
index 0000000..ab4b311
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/index.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+Hello World!
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/index.jsp b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/index.jsp
new file mode 100644
index 0000000..c52acd1
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/main/webapp/index.jsp
@@ -0,0 +1,24 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<html>
+  <head/>
+  <body>
+    <p><% out.print("Hello World!"); %></p>
+  </body>
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/standalonewar/src/test/java/org/glassfish/tests/standalonewar/WebTest.java b/appserver/tests/embedded/maven-plugin/standalonewar/src/test/java/org/glassfish/tests/standalonewar/WebTest.java
new file mode 100644
index 0000000..0909226
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/standalonewar/src/test/java/org/glassfish/tests/standalonewar/WebTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.standalonewar;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 3;
+
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "FILTER", contextPath);
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            URL servlet = new URL("http://localhost:8080/test/ServletTest");
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            String line = null;
+            int index;
+            while ((line = in.readLine()) != null) {
+                index = line.indexOf(result);
+                System.out.println(line);
+                if (index != -1) {
+                    index = line.indexOf(":");
+                    String status = line.substring(index+1);
+
+                    if (status.equalsIgnoreCase("PASS")){
+                        count++;
+                    } else {
+                        return;
+                    }
+                }
+            }
+            Assert.assertTrue(count==3);
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/static-shell-init/pom.xml b/appserver/tests/embedded/maven-plugin/static-shell-init/pom.xml
new file mode 100644
index 0000000..b7fa69e
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/static-shell-init/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>init</artifactId>
+    <packaging>pom</packaging>
+    <name>Bootstrap all tests to use glassfish-static-shell-jar</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.glassfish.main.extras</groupId>
+                        <artifactId>glassfish-embedded-static-shell</artifactId>
+			<scope>system</scope>
+			<version>${project.version}</version>
+			<systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar</systemPath>
+                    </dependency>
+                </dependencies>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/webservice/pom.xml b/appserver/tests/embedded/maven-plugin/webservice/pom.xml
new file mode 100644
index 0000000..713deb5
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/webservice/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>webservice</artifactId>
+    <packaging>war</packaging>
+    <name>WebService Test (maven-plugin/webservice)</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ejb</groupId>
+            <artifactId>javax.ejb-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/webservice/src/main/java/test/SimpleWebService.java b/appserver/tests/embedded/maven-plugin/webservice/src/main/java/test/SimpleWebService.java
new file mode 100644
index 0000000..7e0e9c5
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/webservice/src/main/java/test/SimpleWebService.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package test;
+
+import javax.jws.*;
+
+@WebService
+public class SimpleWebService {
+
+	@WebMethod(operationName="add")
+	public int add(int i, int j) throws Exception {
+		int k = i +j ;
+		System.out.println(i + "+" + j +" = " + k); 
+		return k;
+	}
+
+	@WebMethod(operationName="sayHi")
+	public String sayHi() throws Exception {
+	  System.out.println("hi from SimpleWebService");
+	  return "hi from SimpleWebService";
+	}
+
+}
+
+
diff --git a/appserver/tests/embedded/maven-plugin/webservice/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/webservice/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..1b9a291
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/webservice/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         version="3.0">
+     
+    <session-config>
+        <session-timeout>10</session-timeout>
+    </session-config>
+
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/webservice/src/test/java/org/glassfish/tests/standalonewar/WebTest.java b/appserver/tests/embedded/maven-plugin/webservice/src/test/java/org/glassfish/tests/standalonewar/WebTest.java
new file mode 100644
index 0000000..93eae3b
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/webservice/src/test/java/org/glassfish/tests/standalonewar/WebTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.ejbwar;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+import javax.naming.InitialContext;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 3;
+
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "SimpleWebServicePort", contextPath);
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            URL servlet = new URL("http://localhost:8080/test/SimpleWebServiceService?wsdl");
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            String line = null;
+            int index;
+            while ((line = in.readLine()) != null) {
+                System.out.println(line);
+                index = line.indexOf(result);
+                if (index != -1) {
+                    index = line.indexOf(":");
+                    String status = line.substring(index+1);
+
+                    if (status.equalsIgnoreCase("PASS")){
+                        count++;
+                    } else {
+                        return;
+                    }
+                }
+            }
+            Assert.assertTrue(count==3);
+
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/maven-plugin/websockets/pom.xml b/appserver/tests/embedded/maven-plugin/websockets/pom.xml
new file mode 100644
index 0000000..7e8756a
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/pom.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>maven-plugin</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.maven-plugin</groupId>
+    <artifactId>websockets</artifactId>
+    <packaging>war</packaging>
+    <name>WebSocket Test (maven-plugin/websockets)</name>
+
+    <build>
+        <defaultGoal>install</defaultGoal>
+        <testSourceDirectory>src/test/java</testSourceDirectory>
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.embedded</groupId>
+                <artifactId>maven-embedded-glassfish-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>start</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>start</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>admin</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>admin</goal>
+                        </goals>
+                        <configuration>
+                            <commands>
+                                <param>set configs.config.server-config.network-config.protocols.protocol.http-listener.http.websockets-support-enabled=true</param>
+                            </commands>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>deploy</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>deploy</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>stop</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>undeploy</goal>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-websockets</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-http-servlet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
+
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/LICENSE.md b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/LICENSE.md
new file mode 100644
index 0000000..e0358f9
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/LICENSE.md
@@ -0,0 +1,29 @@
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+   
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions
+    are met:
+   
+      - Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+   
+      - Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+   
+      - Neither the name of the Eclipse Foundation, Inc. nor the names of its
+        contributors may be used to endorse or promote products derived
+        from this software without specific prior written permission.
+   
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+    PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/README.md b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/README.md
new file mode 100644
index 0000000..766dda6
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/README.md
@@ -0,0 +1 @@
+This directory contains sample code and hence files within this directory and below are covered under EDL 1.0.
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/ChatApplication.java b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/ChatApplication.java
new file mode 100644
index 0000000..3f3f92e
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/ChatApplication.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0, which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package com.sun.grizzly.samples.websockets;
+
+import java.util.logging.Level;
+
+import org.glassfish.grizzly.Connection;
+import org.glassfish.grizzly.http.HttpRequestPacket;;
+import org.glassfish.grizzly.websockets.DataFrame;
+import org.glassfish.grizzly.websockets.NetworkHandler;
+import org.glassfish.grizzly.websockets.WebSocket;
+import org.glassfish.grizzly.websockets.WebSocketApplication;
+import org.glassfish.grizzly.websockets.WebSocketListener;
+
+import java.io.IOException;
+
+public class ChatApplication extends WebSocketApplication {
+    @Override
+    public boolean isApplicationRequest(HttpRequestPacket request) {
+        return "/chat".equals(request.getRequestURI());
+    }
+
+    @Override
+    public WebSocket createSocket(final Connection connection, WebSocketListener... listeners) {
+        return new ChatWebSocket(listeners);
+    }
+
+    public void onMessage(WebSocket socket, DataFrame frame) throws IOException {
+        final String data = frame.getTextPayload();
+        if (data.startsWith("login:")) {
+            login((ChatWebSocket) socket, frame);
+        } else {
+            broadcast(((ChatWebSocket) socket).getUser(), data);
+        }
+    }
+
+    @Override
+    public void onClose(WebSocket websocket) {
+        broadcast("system", ((ChatWebSocket)websocket).getUser() + " left the chat");
+    }
+
+    /**
+     * Broadcasts the text message from the user.
+     *
+     * @param user the user name
+     * @param text the text message
+     */
+    private void broadcast(String user, String text) {
+        WebSocketsServlet.logger.log(Level.INFO, "Broadcasting: {0} from: {1}", new Object[]{text, user});
+        for (WebSocket websocket : getWebSockets()) {
+            final ChatWebSocket chat = (ChatWebSocket) websocket;
+            if (chat.getUser() != null) {  // it may happen some websocket is on the list, but not logged in to the chat
+                chat.sendJson(user, text);
+            }
+        }
+
+    }
+
+    private void login(ChatWebSocket socket, DataFrame frame) throws IOException {
+        if (socket.getUser() == null) {
+            WebSocketsServlet.logger.info("ChatApplication.login");
+            socket.setUser(frame.getTextPayload().split(":")[1].trim());
+            broadcast(socket.getUser(), " has joined the chat.");
+        }
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/ChatWebSocket.java b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/ChatWebSocket.java
new file mode 100644
index 0000000..cf97a2d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/ChatWebSocket.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0, which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package com.sun.grizzly.samples.websockets;
+
+import org.glassfish.grizzly.websockets.BaseWebSocket;
+import org.glassfish.grizzly.websockets.NetworkHandler;
+import org.glassfish.grizzly.websockets.WebSocketListener;
+import org.glassfish.grizzly.websockets.WebSocketException;
+
+import java.util.logging.Level;
+import java.io.IOException;
+
+public class ChatWebSocket extends BaseWebSocket {
+    private volatile String user;
+
+    public ChatWebSocket(WebSocketListener... listeners) {
+        super(listeners);
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    /**
+     * Send the message in JSON encoding acceptable by browser's javascript.
+     *
+     * @param user the user name
+     * @param text the text message
+     */
+    public void sendJson(String user, String text) {
+        try {
+            final String msg = toJsonp(user, text);
+            send(msg);
+        } catch (WebSocketException e) {
+            WebSocketsServlet.logger.log(Level.SEVERE, "Removing chat client: " + e.getMessage(), e);
+            close(PROTOCOL_ERROR, e.getMessage());
+        }
+    }
+
+    private String toJsonp(String name, String message) {
+        return "window.parent.app.update({ name: \"" + escape(name) +
+                "\", message: \"" + escape(message) + "\" });\n";
+    }
+
+    private String escape(String orig) {
+        StringBuilder buffer = new StringBuilder(orig.length());
+
+        for (int i = 0; i < orig.length(); i++) {
+            char c = orig.charAt(i);
+            switch (c) {
+                case '\b':
+                    buffer.append("\\b");
+                    break;
+                case '\f':
+                    buffer.append("\\f");
+                    break;
+                case '\n':
+                    buffer.append("<br />");
+                    break;
+                case '\r':
+                    // ignore
+                    break;
+                case '\t':
+                    buffer.append("\\t");
+                    break;
+                case '\'':
+                    buffer.append("\\'");
+                    break;
+                case '\"':
+                    buffer.append("\\\"");
+                    break;
+                case '\\':
+                    buffer.append("\\\\");
+                    break;
+                case '<':
+                    buffer.append("&lt;");
+                    break;
+                case '>':
+                    buffer.append("&gt;");
+                    break;
+                case '&':
+                    buffer.append("&amp;");
+                    break;
+                default:
+                    buffer.append(c);
+            }
+        }
+
+        return buffer.toString();
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/WebSocketsServlet.java b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/WebSocketsServlet.java
new file mode 100755
index 0000000..b017fa1
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/com/sun/grizzly/samples/websockets/WebSocketsServlet.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0, which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package com.sun.grizzly.samples.websockets;
+
+import org.glassfish.grizzly.websockets.WebSocketEngine;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import java.util.logging.Logger;
+
+public class WebSocketsServlet extends HttpServlet {
+    static final Logger logger = Logger.getLogger(WebSocketEngine.WEBSOCKET);
+    private final ChatApplication app = new ChatApplication();
+    @Override
+    public void init(ServletConfig config) throws ServletException {
+        WebSocketEngine.getEngine().register(new ChatApplication());
+    }
+}
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/java/test/.gitkeep_empty_dir b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/test/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/java/test/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/META-INF/context.xml b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/META-INF/context.xml
new file mode 100755
index 0000000..a58c4d0
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<Context path=""/>
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..25b6108
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<sun-web-app>
+    <context-root>/grizzly-websockets-chat</context-root>
+</sun-web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..54df8e7
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+  xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+  <description>Ajax WebSockets Application</description>
+  <display-name>Ajax Chat Websockets</display-name>
+  <servlet>
+    <description>AjaxChatWebSockets</description>
+    <servlet-name>WebSocketsServlet</servlet-name>
+    <servlet-class>com.sun.grizzly.samples.websockets.WebSocketsServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>WebSocketsServlet</servlet-name>
+    <url-pattern>/chat</url-pattern>
+  </servlet-mapping>
+  <session-config>
+    <session-timeout>25</session-timeout>
+  </session-config>
+</web-app>
+
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/body-background.png b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/body-background.png
new file mode 100755
index 0000000..ece11eb
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/body-background.png
Binary files differ
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/header-background.png b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/header-background.png
new file mode 100755
index 0000000..93e4a49
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/header-background.png
Binary files differ
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/main-background.png b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/main-background.png
new file mode 100755
index 0000000..e94cb2d
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/images/main-background.png
Binary files differ
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/index.html b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/index.html
new file mode 100755
index 0000000..36adfc2
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/index.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+        <title>Glassfish Chat</title>
+        <link rel="stylesheet" href="stylesheets/default.css" type="text/css" />
+        <script type="text/javascript" src="javascripts/prototype.js"></script>
+        <script type="text/javascript" src="javascripts/moo.fx.js"></script>
+        <script type="text/javascript" src="javascripts/moo.fx.pack.js"></script>
+        <script type="text/javascript" src="javascripts/application.js"></script>
+    </head>
+    <body>
+        <div id="container">
+            <div id="container-inner">
+                <div id="header">
+                    <h1>Glassfish Chat</h1>
+                </div>
+                <div id="main">
+                    <div id="display">
+                    </div>
+                    <div id="form">
+                        <div id="system-message">Please input your name:</div>
+                        <div id="login-form">
+                            <input id="login-name" type="text" />
+                            <br />
+                            <input id="login-button" type="button" value="Login" />
+                            <br/>
+                            <div id="missing-sockets">Your browser does not support websockets.</div>
+                        </div>
+                        <div id="message-form" style="display: none;">
+                            <div>
+                                <textarea id="message" name="message" rows="2" cols="40"></textarea>
+                                <br />
+                                <input id="post-button" type="button" value="Post Message" />
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <iframe id="websockets-frame" style="display: none;"></iframe>
+    </body>
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/index.jsp b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/index.jsp
new file mode 100644
index 0000000..c52acd1
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/index.jsp
@@ -0,0 +1,24 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<html>
+  <head/>
+  <body>
+    <p><% out.print("Hello World!"); %></p>
+  </body>
+</html>
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/application.js b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/application.js
new file mode 100755
index 0000000..9f1ea20
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/application.js
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+var count = 0;
+var loop = 0;
+var websocket = null;
+var name  = null;
+var url = 'ws://' + document.location.host + document.location.pathname + 'chat';
+
+var app = {
+    initialize: function() {
+        if ("WebSocket" in window) {
+            $('login-name').focus();
+            app.listen();
+        } else {
+            $('missing-sockets').style.display = 'inherit';
+            $('login-name').style.display = 'none';
+            $('login-button').style.display = 'none';
+            $('display').style.display = 'none';
+        }
+    },
+    listen: function() {
+        $('websockets-frame').src = app.url + '?' + count;
+        count ++;
+    },
+    login: function() {
+        name = $F('login-name');
+        if (! name.length > 0) {
+            $('system-message').style.color = 'red';
+            $('login-name').focus();
+            return;
+        }
+        $('system-message').style.color = '#2d2b3d';
+        $('system-message').innerHTML = name + ':';
+
+        $('login-button').disabled = true;
+        $('login-form').style.display = 'none';
+        $('message-form').style.display = '';
+
+        websocket = new WebSocket(url);
+        websocket.name = name;
+        websocket.onopen = function() {
+            // Web Socket is connected. You can send data by send() method
+            websocket.send('login:' + name);
+        };
+        websocket.onmessage = function (evt) {
+            eval(evt.data);
+            $('message').disabled = false;
+            $('post-button').disabled = false;
+            $('message').focus();
+            $('message').value = '';
+        };
+        websocket.onclose = function() {
+            var p = document.createElement('p');
+            p.innerHTML = name + ': has left the chat';
+
+            $('display').appendChild(p);
+
+            new Fx.Scroll('display').down();
+        };
+    },
+    post: function() {
+        var message = $F('message');
+        if (!message > 0) {
+            return;
+        }
+        $('message').disabled = true;
+        $('post-button').disabled = true;
+
+        websocket.send(message);
+    },
+    update: function(data) {
+        if (data) {
+            var p = document.createElement('p');
+            p.innerHTML = data.message;
+
+            $('display').appendChild(p);
+
+            new Fx.Scroll('display').down();
+        }
+    }
+};
+
+var rules = {
+    '#login-name': function(elem) {
+        Event.observe(elem, 'keydown', function(e) {
+            if (e.keyCode == 13) {
+                $('login-button').focus();
+            }
+        });
+    },
+    '#login-button': function(elem) {
+        elem.onclick = app.login;
+    },
+    '#message': function(elem) {
+        Event.observe(elem, 'keydown', function(e) {
+            if (e.shiftKey && e.keyCode == 13) {
+                $('post-button').focus();
+            }
+        });
+    },
+    '#post-button': function(elem) {
+        elem.onclick = app.post;
+    }
+};
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/moo.fx.js b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/moo.fx.js
new file mode 100755
index 0000000..5ea777c
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/moo.fx.js
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+var Fx = fx = {};
+
+Fx.Base = function(){};
+Fx.Base.prototype = {
+
+	setOptions: function(options){
+		this.options = Object.extend({
+			onStart: function(){},
+			onComplete: function(){},
+			duration: 500,
+			unit: 'px',
+			wait: true,
+			fps: 50
+		}, options || {});
+	},
+
+	step: function(){
+		var time = new Date().getTime();
+		if (time < this.time + this.options.duration){
+			this.cTime = time - this.time;
+			this.setNow();
+		} else {
+			setTimeout(this.options.onComplete.bind(this, this.element), 10);
+			this.clearTimer();
+			this.now = this.to;
+		}
+		this.increase();
+	},
+
+	setNow: function(){
+		this.now = this.compute(this.from, this.to);
+	},
+
+	compute: function(from, to){
+		var change = to - from;
+		return this.options.transition(this.cTime, from, change, this.options.duration);
+	},
+
+	clearTimer: function(){
+		clearInterval(this.timer);
+		this.timer = null;
+		return this;
+	},
+
+	_start: function(from, to){
+		if (!this.options.wait) this.clearTimer();
+		if (this.timer) return;
+		setTimeout(this.options.onStart.bind(this, this.element), 10);
+		this.from = from;
+		this.to = to;
+		this.time = new Date().getTime();
+		this.timer = setInterval(this.step.bind(this), Math.round(1000/this.options.fps));
+		return this;
+	},
+
+	custom: function(from, to){
+		return this._start(from, to);
+	},
+
+	set: function(to){
+		this.now = to;
+		this.increase();
+		return this;
+	},
+
+	hide: function(){
+		return this.set(0);
+	},
+
+	setStyle: function(e, p, v){
+		if (p == 'opacity'){
+			if (v == 0 && e.style.visibility != "hidden") e.style.visibility = "hidden";
+			else if (e.style.visibility != "visible") e.style.visibility = "visible";
+			if (window.ActiveXObject) e.style.filter = "alpha(opacity=" + v*100 + ")";
+			e.style.opacity = v;
+		} else e.style[p] = v+this.options.unit;
+	}
+
+};
+
+Fx.Style = Class.create();
+Fx.Style.prototype = Object.extend(new Fx.Base(), {
+
+	initialize: function(el, property, options){
+		this.element = $(el);
+		this.setOptions(options);
+		this.property = property.camelize();
+	},
+
+	increase: function(){
+		this.setStyle(this.element, this.property, this.now);
+	}
+
+});
+
+Fx.Styles = Class.create();
+Fx.Styles.prototype = Object.extend(new Fx.Base(), {
+
+	initialize: function(el, options){
+		this.element = $(el);
+		this.setOptions(options);
+		this.now = {};
+	},
+
+	setNow: function(){
+		for (p in this.from) this.now[p] = this.compute(this.from[p], this.to[p]);
+	},
+
+	custom: function(obj){
+		if (this.timer && this.options.wait) return;
+		var from = {};
+		var to = {};
+		for (p in obj){
+			from[p] = obj[p][0];
+			to[p] = obj[p][1];
+		}
+		return this._start(from, to);
+	},
+
+	increase: function(){
+		for (var p in this.now) this.setStyle(this.element, p, this.now[p]);
+	}
+
+});
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/moo.fx.pack.js b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/moo.fx.pack.js
new file mode 100755
index 0000000..8d26388
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/moo.fx.pack.js
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+Fx.Scroll = Class.create();
+Fx.Scroll.prototype = Object.extend(new Fx.Base(), {
+
+	initialize: function(el, options) {
+		this.element = $(el);
+		this.setOptions(options);
+		this.element.style.overflow = 'hidden';
+	},
+	
+	down: function(){
+		return this.custom(this.element.scrollTop, this.element.scrollHeight-this.element.offsetHeight);
+	},
+	
+	up: function(){
+		return this.custom(this.element.scrollTop, 0);
+	},
+
+	increase: function(){
+		this.element.scrollTop = this.now;
+	}
+
+});
+
+//fx.Color, originally by Tom Jensen (http://neuemusic.com) MIT-style LICENSE.
+
+Fx.Color = Class.create();
+Fx.Color.prototype = Object.extend(new Fx.Base(), {
+	
+	initialize: function(el, property, options){
+		this.element = $(el);
+		this.setOptions(options);
+		this.property = property.camelize();
+		this.now = [];
+	},
+
+	custom: function(from, to){
+		return this._start(from.hexToRgb(true), to.hexToRgb(true));
+	},
+
+	setNow: function(){
+		[0,1,2].each(function(i){
+			this.now[i] = Math.round(this.compute(this.from[i], this.to[i]));
+		}.bind(this));
+	},
+
+	increase: function(){
+		this.element.style[this.property] = "rgb("+this.now[0]+","+this.now[1]+","+this.now[2]+")";
+	}
+
+});
+
+Object.extend(String.prototype, {
+
+	rgbToHex: function(array){
+		var rgb = this.match(new RegExp('([\\d]{1,3})', 'g'));
+		if (rgb[3] == 0) return 'transparent';
+		var hex = [];
+		for (var i = 0; i < 3; i++){
+			var bit = (rgb[i]-0).toString(16);
+			hex.push(bit.length == 1 ? '0'+bit : bit);
+		}
+		var hexText = '#'+hex.join('');
+		if (array) return hex;
+		else return hexText;
+	},
+
+	hexToRgb: function(array){
+		var hex = this.match(new RegExp('^[#]{0,1}([\\w]{1,2})([\\w]{1,2})([\\w]{1,2})$'));
+		var rgb = [];
+		for (var i = 1; i < hex.length; i++){
+			if (hex[i].length == 1) hex[i] += hex[i];
+			rgb.push(parseInt(hex[i], 16));
+		}
+		var rgbText = 'rgb('+rgb.join(',')+')';
+		if (array) return rgb;
+		else return rgbText;
+	}	
+
+});
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/prototype.js b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/prototype.js
new file mode 100755
index 0000000..c0e8138
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/javascripts/prototype.js
@@ -0,0 +1,1789 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+var Prototype = {
+  Version: '1.4.0',
+  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
+
+  emptyFunction: function() {},
+  K: function(x) {return x}
+}
+
+var Class = {
+  create: function() {
+    return function() {
+      this.initialize.apply(this, arguments);
+    }
+  }
+}
+
+var Abstract = new Object();
+
+Object.extend = function(destination, source) {
+  for (property in source) {
+    destination[property] = source[property];
+  }
+  return destination;
+}
+
+Object.inspect = function(object) {
+  try {
+    if (object == undefined) return 'undefined';
+    if (object == null) return 'null';
+    return object.inspect ? object.inspect() : object.toString();
+  } catch (e) {
+    if (e instanceof RangeError) return '...';
+    throw e;
+  }
+}
+
+Function.prototype.bind = function() {
+  var __method = this, args = $A(arguments), object = args.shift();
+  return function() {
+    return __method.apply(object, args.concat($A(arguments)));
+  }
+}
+
+Function.prototype.bindAsEventListener = function(object) {
+  var __method = this;
+  return function(event) {
+    return __method.call(object, event || window.event);
+  }
+}
+
+Object.extend(Number.prototype, {
+  toColorPart: function() {
+    var digits = this.toString(16);
+    if (this < 16) return '0' + digits;
+    return digits;
+  },
+
+  succ: function() {
+    return this + 1;
+  },
+
+  times: function(iterator) {
+    $R(0, this, true).each(iterator);
+    return this;
+  }
+});
+
+var Try = {
+  these: function() {
+    var returnValue;
+
+    for (var i = 0; i < arguments.length; i++) {
+      var lambda = arguments[i];
+      try {
+        returnValue = lambda();
+        break;
+      } catch (e) {}
+    }
+
+    return returnValue;
+  }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var PeriodicalExecuter = Class.create();
+PeriodicalExecuter.prototype = {
+  initialize: function(callback, frequency) {
+    this.callback = callback;
+    this.frequency = frequency;
+    this.currentlyExecuting = false;
+
+    this.registerCallback();
+  },
+
+  registerCallback: function() {
+    setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+  },
+
+  onTimerEvent: function() {
+    if (!this.currentlyExecuting) {
+      try {
+        this.currentlyExecuting = true;
+        this.callback();
+      } finally {
+        this.currentlyExecuting = false;
+      }
+    }
+  }
+}
+
+/*--------------------------------------------------------------------------*/
+
+function $() {
+  var elements = new Array();
+
+  for (var i = 0; i < arguments.length; i++) {
+    var element = arguments[i];
+    if (typeof element == 'string')
+      element = document.getElementById(element);
+
+    if (arguments.length == 1)
+      return element;
+
+    elements.push(element);
+  }
+
+  return elements;
+}
+Object.extend(String.prototype, {
+  stripTags: function() {
+    return this.replace(/<\/?[^>]+>/gi, '');
+  },
+
+  stripScripts: function() {
+    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
+  },
+
+  extractScripts: function() {
+    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
+    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
+    return (this.match(matchAll) || []).map(function(scriptTag) {
+      return (scriptTag.match(matchOne) || ['', ''])[1];
+    });
+  },
+
+  evalScripts: function() {
+    return this.extractScripts().map(eval);
+  },
+
+  escapeHTML: function() {
+    var div = document.createElement('div');
+    var text = document.createTextNode(this);
+    div.appendChild(text);
+    return div.innerHTML;
+  },
+
+  unescapeHTML: function() {
+    var div = document.createElement('div');
+    div.innerHTML = this.stripTags();
+    return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
+  },
+
+  toQueryParams: function() {
+    var pairs = this.match(/^\??(.*)$/)[1].split('&');
+    return pairs.inject({}, function(params, pairString) {
+      var pair = pairString.split('=');
+      params[pair[0]] = pair[1];
+      return params;
+    });
+  },
+
+  toArray: function() {
+    return this.split('');
+  },
+
+  camelize: function() {
+    var oStringList = this.split('-');
+    if (oStringList.length == 1) return oStringList[0];
+
+    var camelizedString = this.indexOf('-') == 0
+      ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
+      : oStringList[0];
+
+    for (var i = 1, len = oStringList.length; i < len; i++) {
+      var s = oStringList[i];
+      camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
+    }
+
+    return camelizedString;
+  },
+
+  inspect: function() {
+    return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
+  }
+});
+
+String.prototype.parseQuery = String.prototype.toQueryParams;
+
+var $break    = new Object();
+var $continue = new Object();
+
+var Enumerable = {
+  each: function(iterator) {
+    var index = 0;
+    try {
+      this._each(function(value) {
+        try {
+          iterator(value, index++);
+        } catch (e) {
+          if (e != $continue) throw e;
+        }
+      });
+    } catch (e) {
+      if (e != $break) throw e;
+    }
+  },
+
+  all: function(iterator) {
+    var result = true;
+    this.each(function(value, index) {
+      result = result && !!(iterator || Prototype.K)(value, index);
+      if (!result) throw $break;
+    });
+    return result;
+  },
+
+  any: function(iterator) {
+    var result = true;
+    this.each(function(value, index) {
+      if (result = !!(iterator || Prototype.K)(value, index))
+        throw $break;
+    });
+    return result;
+  },
+
+  collect: function(iterator) {
+    var results = [];
+    this.each(function(value, index) {
+      results.push(iterator(value, index));
+    });
+    return results;
+  },
+
+  detect: function (iterator) {
+    var result;
+    this.each(function(value, index) {
+      if (iterator(value, index)) {
+        result = value;
+        throw $break;
+      }
+    });
+    return result;
+  },
+
+  findAll: function(iterator) {
+    var results = [];
+    this.each(function(value, index) {
+      if (iterator(value, index))
+        results.push(value);
+    });
+    return results;
+  },
+
+  grep: function(pattern, iterator) {
+    var results = [];
+    this.each(function(value, index) {
+      var stringValue = value.toString();
+      if (stringValue.match(pattern))
+        results.push((iterator || Prototype.K)(value, index));
+    })
+    return results;
+  },
+
+  include: function(object) {
+    var found = false;
+    this.each(function(value) {
+      if (value == object) {
+        found = true;
+        throw $break;
+      }
+    });
+    return found;
+  },
+
+  inject: function(memo, iterator) {
+    this.each(function(value, index) {
+      memo = iterator(memo, value, index);
+    });
+    return memo;
+  },
+
+  invoke: function(method) {
+    var args = $A(arguments).slice(1);
+    return this.collect(function(value) {
+      return value[method].apply(value, args);
+    });
+  },
+
+  max: function(iterator) {
+    var result;
+    this.each(function(value, index) {
+      value = (iterator || Prototype.K)(value, index);
+      if (value >= (result || value))
+        result = value;
+    });
+    return result;
+  },
+
+  min: function(iterator) {
+    var result;
+    this.each(function(value, index) {
+      value = (iterator || Prototype.K)(value, index);
+      if (value <= (result || value))
+        result = value;
+    });
+    return result;
+  },
+
+  partition: function(iterator) {
+    var trues = [], falses = [];
+    this.each(function(value, index) {
+      ((iterator || Prototype.K)(value, index) ?
+        trues : falses).push(value);
+    });
+    return [trues, falses];
+  },
+
+  pluck: function(property) {
+    var results = [];
+    this.each(function(value, index) {
+      results.push(value[property]);
+    });
+    return results;
+  },
+
+  reject: function(iterator) {
+    var results = [];
+    this.each(function(value, index) {
+      if (!iterator(value, index))
+        results.push(value);
+    });
+    return results;
+  },
+
+  sortBy: function(iterator) {
+    return this.collect(function(value, index) {
+      return {value: value, criteria: iterator(value, index)};
+    }).sort(function(left, right) {
+      var a = left.criteria, b = right.criteria;
+      return a < b ? -1 : a > b ? 1 : 0;
+    }).pluck('value');
+  },
+
+  toArray: function() {
+    return this.collect(Prototype.K);
+  },
+
+  zip: function() {
+    var iterator = Prototype.K, args = $A(arguments);
+    if (typeof args.last() == 'function')
+      iterator = args.pop();
+
+    var collections = [this].concat(args).map($A);
+    return this.map(function(value, index) {
+      iterator(value = collections.pluck(index));
+      return value;
+    });
+  },
+
+  inspect: function() {
+    return '#<Enumerable:' + this.toArray().inspect() + '>';
+  }
+}
+
+Object.extend(Enumerable, {
+  map:     Enumerable.collect,
+  find:    Enumerable.detect,
+  select:  Enumerable.findAll,
+  member:  Enumerable.include,
+  entries: Enumerable.toArray
+});
+var $A = Array.from = function(iterable) {
+  if (!iterable) return [];
+  if (iterable.toArray) {
+    return iterable.toArray();
+  } else {
+    var results = [];
+    for (var i = 0; i < iterable.length; i++)
+      results.push(iterable[i]);
+    return results;
+  }
+}
+
+Object.extend(Array.prototype, Enumerable);
+
+Array.prototype._reverse = Array.prototype.reverse;
+
+Object.extend(Array.prototype, {
+  _each: function(iterator) {
+    for (var i = 0; i < this.length; i++)
+      iterator(this[i]);
+  },
+
+  clear: function() {
+    this.length = 0;
+    return this;
+  },
+
+  first: function() {
+    return this[0];
+  },
+
+  last: function() {
+    return this[this.length - 1];
+  },
+
+  compact: function() {
+    return this.select(function(value) {
+      return value != undefined || value != null;
+    });
+  },
+
+  flatten: function() {
+    return this.inject([], function(array, value) {
+      return array.concat(value.constructor == Array ?
+        value.flatten() : [value]);
+    });
+  },
+
+  without: function() {
+    var values = $A(arguments);
+    return this.select(function(value) {
+      return !values.include(value);
+    });
+  },
+
+  indexOf: function(object) {
+    for (var i = 0; i < this.length; i++)
+      if (this[i] == object) return i;
+    return -1;
+  },
+
+  reverse: function(inline) {
+    return (inline !== false ? this : this.toArray())._reverse();
+  },
+
+  shift: function() {
+    var result = this[0];
+    for (var i = 0; i < this.length - 1; i++)
+      this[i] = this[i + 1];
+    this.length--;
+    return result;
+  },
+
+  inspect: function() {
+    return '[' + this.map(Object.inspect).join(', ') + ']';
+  }
+});
+var Hash = {
+  _each: function(iterator) {
+    for (key in this) {
+      var value = this[key];
+      if (typeof value == 'function') continue;
+
+      var pair = [key, value];
+      pair.key = key;
+      pair.value = value;
+      iterator(pair);
+    }
+  },
+
+  keys: function() {
+    return this.pluck('key');
+  },
+
+  values: function() {
+    return this.pluck('value');
+  },
+
+  merge: function(hash) {
+    return $H(hash).inject($H(this), function(mergedHash, pair) {
+      mergedHash[pair.key] = pair.value;
+      return mergedHash;
+    });
+  },
+
+  toQueryString: function() {
+    return this.map(function(pair) {
+      return pair.map(encodeURIComponent).join('=');
+    }).join('&');
+  },
+
+  inspect: function() {
+    return '#<Hash:{' + this.map(function(pair) {
+      return pair.map(Object.inspect).join(': ');
+    }).join(', ') + '}>';
+  }
+}
+
+function $H(object) {
+  var hash = Object.extend({}, object || {});
+  Object.extend(hash, Enumerable);
+  Object.extend(hash, Hash);
+  return hash;
+}
+ObjectRange = Class.create();
+Object.extend(ObjectRange.prototype, Enumerable);
+Object.extend(ObjectRange.prototype, {
+  initialize: function(start, end, exclusive) {
+    this.start = start;
+    this.end = end;
+    this.exclusive = exclusive;
+  },
+
+  _each: function(iterator) {
+    var value = this.start;
+    do {
+      iterator(value);
+      value = value.succ();
+    } while (this.include(value));
+  },
+
+  include: function(value) {
+    if (value < this.start)
+      return false;
+    if (this.exclusive)
+      return value < this.end;
+    return value <= this.end;
+  }
+});
+
+var $R = function(start, end, exclusive) {
+  return new ObjectRange(start, end, exclusive);
+}
+
+var Ajax = {
+  getTransport: function() {
+    return Try.these(
+      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
+      function() {return new ActiveXObject('Microsoft.XMLHTTP')},
+      function() {return new XMLHttpRequest()}
+    ) || false;
+  },
+
+  activeRequestCount: 0
+}
+
+Ajax.Responders = {
+  responders: [],
+
+  _each: function(iterator) {
+    this.responders._each(iterator);
+  },
+
+  register: function(responderToAdd) {
+    if (!this.include(responderToAdd))
+      this.responders.push(responderToAdd);
+  },
+
+  unregister: function(responderToRemove) {
+    this.responders = this.responders.without(responderToRemove);
+  },
+
+  dispatch: function(callback, request, transport, json) {
+    this.each(function(responder) {
+      if (responder[callback] && typeof responder[callback] == 'function') {
+        try {
+          responder[callback].apply(responder, [request, transport, json]);
+        } catch (e) {}
+      }
+    });
+  }
+};
+
+Object.extend(Ajax.Responders, Enumerable);
+
+Ajax.Responders.register({
+  onCreate: function() {
+    Ajax.activeRequestCount++;
+  },
+
+  onComplete: function() {
+    Ajax.activeRequestCount--;
+  }
+});
+
+Ajax.Base = function() {};
+Ajax.Base.prototype = {
+  setOptions: function(options) {
+    this.options = {
+      method:       'post',
+      asynchronous: true,
+      parameters:   ''
+    }
+    Object.extend(this.options, options || {});
+  },
+
+  responseIsSuccess: function() {
+    return this.transport.status == undefined
+        || this.transport.status == 0
+        || (this.transport.status >= 200 && this.transport.status < 300);
+  },
+
+  responseIsFailure: function() {
+    return !this.responseIsSuccess();
+  }
+}
+
+Ajax.Request = Class.create();
+Ajax.Request.Events =
+  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
+
+Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
+  initialize: function(url, options) {
+    this.transport = Ajax.getTransport();
+    this.setOptions(options);
+    this.request(url);
+  },
+
+  request: function(url) {
+    var parameters = this.options.parameters || '';
+    if (parameters.length > 0) parameters += '&_=';
+
+    try {
+      this.url = url;
+      if (this.options.method == 'get' && parameters.length > 0)
+        this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
+
+      Ajax.Responders.dispatch('onCreate', this, this.transport);
+
+      this.transport.open(this.options.method, this.url,
+        this.options.asynchronous);
+
+      if (this.options.asynchronous) {
+        this.transport.onreadystatechange = this.onStateChange.bind(this);
+        setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
+      }
+
+      this.setRequestHeaders();
+
+      var body = this.options.postBody ? this.options.postBody : parameters;
+      this.transport.send(this.options.method == 'post' ? body : null);
+
+    } catch (e) {
+      this.dispatchException(e);
+    }
+  },
+
+  setRequestHeaders: function() {
+    var requestHeaders =
+      ['X-Requested-With', 'XMLHttpRequest',
+       'X-Prototype-Version', Prototype.Version];
+
+    if (this.options.method == 'post') {
+      requestHeaders.push('Content-type',
+        'application/x-www-form-urlencoded');
+
+      /* Force "Connection: close" for Mozilla browsers to work around
+       * a bug where XMLHttpReqeuest sends an incorrect Content-length
+       * header. See Mozilla Bugzilla #246651.
+       */
+      if (this.transport.overrideMimeType)
+        requestHeaders.push('Connection', 'close');
+    }
+
+    if (this.options.requestHeaders)
+      requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
+
+    for (var i = 0; i < requestHeaders.length; i += 2)
+      this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
+  },
+
+  onStateChange: function() {
+    var readyState = this.transport.readyState;
+    if (readyState != 1)
+      this.respondToReadyState(this.transport.readyState);
+  },
+
+  header: function(name) {
+    try {
+      return this.transport.getResponseHeader(name);
+    } catch (e) {}
+  },
+
+  evalJSON: function() {
+    try {
+      return eval(this.header('X-JSON'));
+    } catch (e) {}
+  },
+
+  evalResponse: function() {
+    try {
+      return eval(this.transport.responseText);
+    } catch (e) {
+      this.dispatchException(e);
+    }
+  },
+
+  respondToReadyState: function(readyState) {
+    var event = Ajax.Request.Events[readyState];
+    var transport = this.transport, json = this.evalJSON();
+
+    if (event == 'Complete') {
+      try {
+        (this.options['on' + this.transport.status]
+         || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
+         || Prototype.emptyFunction)(transport, json);
+      } catch (e) {
+        this.dispatchException(e);
+      }
+
+      if ((this.header('Content-type') || '').match(/^text\/javascript/i))
+        this.evalResponse();
+    }
+
+    try {
+      (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
+      Ajax.Responders.dispatch('on' + event, this, transport, json);
+    } catch (e) {
+      this.dispatchException(e);
+    }
+
+    /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
+    if (event == 'Complete')
+      this.transport.onreadystatechange = Prototype.emptyFunction;
+  },
+
+  dispatchException: function(exception) {
+    (this.options.onException || Prototype.emptyFunction)(this, exception);
+    Ajax.Responders.dispatch('onException', this, exception);
+  }
+});
+
+Ajax.Updater = Class.create();
+
+Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
+  initialize: function(container, url, options) {
+    this.containers = {
+      success: container.success ? $(container.success) : $(container),
+      failure: container.failure ? $(container.failure) :
+        (container.success ? null : $(container))
+    }
+
+    this.transport = Ajax.getTransport();
+    this.setOptions(options);
+
+    var onComplete = this.options.onComplete || Prototype.emptyFunction;
+    this.options.onComplete = (function(transport, object) {
+      this.updateContent();
+      onComplete(transport, object);
+    }).bind(this);
+
+    this.request(url);
+  },
+
+  updateContent: function() {
+    var receiver = this.responseIsSuccess() ?
+      this.containers.success : this.containers.failure;
+    var response = this.transport.responseText;
+
+    if (!this.options.evalScripts)
+      response = response.stripScripts();
+
+    if (receiver) {
+      if (this.options.insertion) {
+        new this.options.insertion(receiver, response);
+      } else {
+        Element.update(receiver, response);
+      }
+    }
+
+    if (this.responseIsSuccess()) {
+      if (this.onComplete)
+        setTimeout(this.onComplete.bind(this), 10);
+    }
+  }
+});
+
+Ajax.PeriodicalUpdater = Class.create();
+Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
+  initialize: function(container, url, options) {
+    this.setOptions(options);
+    this.onComplete = this.options.onComplete;
+
+    this.frequency = (this.options.frequency || 2);
+    this.decay = (this.options.decay || 1);
+
+    this.updater = {};
+    this.container = container;
+    this.url = url;
+
+    this.start();
+  },
+
+  start: function() {
+    this.options.onComplete = this.updateComplete.bind(this);
+    this.onTimerEvent();
+  },
+
+  stop: function() {
+    this.updater.onComplete = undefined;
+    clearTimeout(this.timer);
+    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
+  },
+
+  updateComplete: function(request) {
+    if (this.options.decay) {
+      this.decay = (request.responseText == this.lastText ?
+        this.decay * this.options.decay : 1);
+
+      this.lastText = request.responseText;
+    }
+    this.timer = setTimeout(this.onTimerEvent.bind(this),
+      this.decay * this.frequency * 1000);
+  },
+
+  onTimerEvent: function() {
+    this.updater = new Ajax.Updater(this.container, this.url, this.options);
+  }
+});
+document.getElementsByClassName = function(className, parentElement) {
+  var children = ($(parentElement) || document.body).getElementsByTagName('*');
+  return $A(children).inject([], function(elements, child) {
+    if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
+      elements.push(child);
+    return elements;
+  });
+}
+
+/*--------------------------------------------------------------------------*/
+
+if (!window.Element) {
+  var Element = new Object();
+}
+
+Object.extend(Element, {
+  visible: function(element) {
+    return $(element).style.display != 'none';
+  },
+
+  toggle: function() {
+    for (var i = 0; i < arguments.length; i++) {
+      var element = $(arguments[i]);
+      Element[Element.visible(element) ? 'hide' : 'show'](element);
+    }
+  },
+
+  hide: function() {
+    for (var i = 0; i < arguments.length; i++) {
+      var element = $(arguments[i]);
+      element.style.display = 'none';
+    }
+  },
+
+  show: function() {
+    for (var i = 0; i < arguments.length; i++) {
+      var element = $(arguments[i]);
+      element.style.display = '';
+    }
+  },
+
+  remove: function(element) {
+    element = $(element);
+    element.parentNode.removeChild(element);
+  },
+
+  update: function(element, html) {
+    $(element).innerHTML = html.stripScripts();
+    setTimeout(function() {html.evalScripts()}, 10);
+  },
+
+  getHeight: function(element) {
+    element = $(element);
+    return element.offsetHeight;
+  },
+
+  classNames: function(element) {
+    return new Element.ClassNames(element);
+  },
+
+  hasClassName: function(element, className) {
+    if (!(element = $(element))) return;
+    return Element.classNames(element).include(className);
+  },
+
+  addClassName: function(element, className) {
+    if (!(element = $(element))) return;
+    return Element.classNames(element).add(className);
+  },
+
+  removeClassName: function(element, className) {
+    if (!(element = $(element))) return;
+    return Element.classNames(element).remove(className);
+  },
+
+  // removes whitespace-only text node children
+  cleanWhitespace: function(element) {
+    element = $(element);
+    for (var i = 0; i < element.childNodes.length; i++) {
+      var node = element.childNodes[i];
+      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
+        Element.remove(node);
+    }
+  },
+
+  empty: function(element) {
+    return $(element).innerHTML.match(/^\s*$/);
+  },
+
+  scrollTo: function(element) {
+    element = $(element);
+    var x = element.x ? element.x : element.offsetLeft,
+        y = element.y ? element.y : element.offsetTop;
+    window.scrollTo(x, y);
+  },
+
+  getStyle: function(element, style) {
+    element = $(element);
+    var value = element.style[style.camelize()];
+    if (!value) {
+      if (document.defaultView && document.defaultView.getComputedStyle) {
+        var css = document.defaultView.getComputedStyle(element, null);
+        value = css ? css.getPropertyValue(style) : null;
+      } else if (element.currentStyle) {
+        value = element.currentStyle[style.camelize()];
+      }
+    }
+
+    if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
+      if (Element.getStyle(element, 'position') == 'static') value = 'auto';
+
+    return value == 'auto' ? null : value;
+  },
+
+  setStyle: function(element, style) {
+    element = $(element);
+    for (name in style)
+      element.style[name.camelize()] = style[name];
+  },
+
+  getDimensions: function(element) {
+    element = $(element);
+    if (Element.getStyle(element, 'display') != 'none')
+      return {width: element.offsetWidth, height: element.offsetHeight};
+
+    // All *Width and *Height properties give 0 on elements with display none,
+    // so enable the element temporarily
+    var els = element.style;
+    var originalVisibility = els.visibility;
+    var originalPosition = els.position;
+    els.visibility = 'hidden';
+    els.position = 'absolute';
+    els.display = '';
+    var originalWidth = element.clientWidth;
+    var originalHeight = element.clientHeight;
+    els.display = 'none';
+    els.position = originalPosition;
+    els.visibility = originalVisibility;
+    return {width: originalWidth, height: originalHeight};
+  },
+
+  makePositioned: function(element) {
+    element = $(element);
+    var pos = Element.getStyle(element, 'position');
+    if (pos == 'static' || !pos) {
+      element._madePositioned = true;
+      element.style.position = 'relative';
+      // Opera returns the offset relative to the positioning context, when an
+      // element is position relative but top and left have not been defined
+      if (window.opera) {
+        element.style.top = 0;
+        element.style.left = 0;
+      }
+    }
+  },
+
+  undoPositioned: function(element) {
+    element = $(element);
+    if (element._madePositioned) {
+      element._madePositioned = undefined;
+      element.style.position =
+        element.style.top =
+        element.style.left =
+        element.style.bottom =
+        element.style.right = '';
+    }
+  },
+
+  makeClipping: function(element) {
+    element = $(element);
+    if (element._overflow) return;
+    element._overflow = element.style.overflow;
+    if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
+      element.style.overflow = 'hidden';
+  },
+
+  undoClipping: function(element) {
+    element = $(element);
+    if (element._overflow) return;
+    element.style.overflow = element._overflow;
+    element._overflow = undefined;
+  }
+});
+
+var Toggle = new Object();
+Toggle.display = Element.toggle;
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.Insertion = function(adjacency) {
+  this.adjacency = adjacency;
+}
+
+Abstract.Insertion.prototype = {
+  initialize: function(element, content) {
+    this.element = $(element);
+    this.content = content.stripScripts();
+
+    if (this.adjacency && this.element.insertAdjacentHTML) {
+      try {
+        this.element.insertAdjacentHTML(this.adjacency, this.content);
+      } catch (e) {
+        if (this.element.tagName.toLowerCase() == 'tbody') {
+          this.insertContent(this.contentFromAnonymousTable());
+        } else {
+          throw e;
+        }
+      }
+    } else {
+      this.range = this.element.ownerDocument.createRange();
+      if (this.initializeRange) this.initializeRange();
+      this.insertContent([this.range.createContextualFragment(this.content)]);
+    }
+
+    setTimeout(function() {content.evalScripts()}, 10);
+  },
+
+  contentFromAnonymousTable: function() {
+    var div = document.createElement('div');
+    div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>';
+    return $A(div.childNodes[0].childNodes[0].childNodes);
+  }
+}
+
+var Insertion = new Object();
+
+Insertion.Before = Class.create();
+Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
+  initializeRange: function() {
+    this.range.setStartBefore(this.element);
+  },
+
+  insertContent: function(fragments) {
+    fragments.each((function(fragment) {
+      this.element.parentNode.insertBefore(fragment, this.element);
+    }).bind(this));
+  }
+});
+
+Insertion.Top = Class.create();
+Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
+  initializeRange: function() {
+    this.range.selectNodeContents(this.element);
+    this.range.collapse(true);
+  },
+
+  insertContent: function(fragments) {
+    fragments.reverse(false).each((function(fragment) {
+      this.element.insertBefore(fragment, this.element.firstChild);
+    }).bind(this));
+  }
+});
+
+Insertion.Bottom = Class.create();
+Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
+  initializeRange: function() {
+    this.range.selectNodeContents(this.element);
+    this.range.collapse(this.element);
+  },
+
+  insertContent: function(fragments) {
+    fragments.each((function(fragment) {
+      this.element.appendChild(fragment);
+    }).bind(this));
+  }
+});
+
+Insertion.After = Class.create();
+Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
+  initializeRange: function() {
+    this.range.setStartAfter(this.element);
+  },
+
+  insertContent: function(fragments) {
+    fragments.each((function(fragment) {
+      this.element.parentNode.insertBefore(fragment,
+        this.element.nextSibling);
+    }).bind(this));
+  }
+});
+
+/*--------------------------------------------------------------------------*/
+
+Element.ClassNames = Class.create();
+Element.ClassNames.prototype = {
+  initialize: function(element) {
+    this.element = $(element);
+  },
+
+  _each: function(iterator) {
+    this.element.className.split(/\s+/).select(function(name) {
+      return name.length > 0;
+    })._each(iterator);
+  },
+
+  set: function(className) {
+    this.element.className = className;
+  },
+
+  add: function(classNameToAdd) {
+    if (this.include(classNameToAdd)) return;
+    this.set(this.toArray().concat(classNameToAdd).join(' '));
+  },
+
+  remove: function(classNameToRemove) {
+    if (!this.include(classNameToRemove)) return;
+    this.set(this.select(function(className) {
+      return className != classNameToRemove;
+    }).join(' '));
+  },
+
+  toString: function() {
+    return this.toArray().join(' ');
+  }
+}
+
+Object.extend(Element.ClassNames.prototype, Enumerable);
+var Field = {
+  clear: function() {
+    for (var i = 0; i < arguments.length; i++)
+      $(arguments[i]).value = '';
+  },
+
+  focus: function(element) {
+    $(element).focus();
+  },
+
+  present: function() {
+    for (var i = 0; i < arguments.length; i++)
+      if ($(arguments[i]).value == '') return false;
+    return true;
+  },
+
+  select: function(element) {
+    $(element).select();
+  },
+
+  activate: function(element) {
+    element = $(element);
+    element.focus();
+    if (element.select)
+      element.select();
+  }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var Form = {
+  serialize: function(form) {
+    var elements = Form.getElements($(form));
+    var queryComponents = new Array();
+
+    for (var i = 0; i < elements.length; i++) {
+      var queryComponent = Form.Element.serialize(elements[i]);
+      if (queryComponent)
+        queryComponents.push(queryComponent);
+    }
+
+    return queryComponents.join('&');
+  },
+
+  getElements: function(form) {
+    form = $(form);
+    var elements = new Array();
+
+    for (tagName in Form.Element.Serializers) {
+      var tagElements = form.getElementsByTagName(tagName);
+      for (var j = 0; j < tagElements.length; j++)
+        elements.push(tagElements[j]);
+    }
+    return elements;
+  },
+
+  getInputs: function(form, typeName, name) {
+    form = $(form);
+    var inputs = form.getElementsByTagName('input');
+
+    if (!typeName && !name)
+      return inputs;
+
+    var matchingInputs = new Array();
+    for (var i = 0; i < inputs.length; i++) {
+      var input = inputs[i];
+      if ((typeName && input.type != typeName) ||
+          (name && input.name != name))
+        continue;
+      matchingInputs.push(input);
+    }
+
+    return matchingInputs;
+  },
+
+  disable: function(form) {
+    var elements = Form.getElements(form);
+    for (var i = 0; i < elements.length; i++) {
+      var element = elements[i];
+      element.blur();
+      element.disabled = 'true';
+    }
+  },
+
+  enable: function(form) {
+    var elements = Form.getElements(form);
+    for (var i = 0; i < elements.length; i++) {
+      var element = elements[i];
+      element.disabled = '';
+    }
+  },
+
+  findFirstElement: function(form) {
+    return Form.getElements(form).find(function(element) {
+      return element.type != 'hidden' && !element.disabled &&
+        ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
+    });
+  },
+
+  focusFirstElement: function(form) {
+    Field.activate(Form.findFirstElement(form));
+  },
+
+  reset: function(form) {
+    $(form).reset();
+  }
+}
+
+Form.Element = {
+  serialize: function(element) {
+    element = $(element);
+    var method = element.tagName.toLowerCase();
+    var parameter = Form.Element.Serializers[method](element);
+
+    if (parameter) {
+      var key = encodeURIComponent(parameter[0]);
+      if (key.length == 0) return;
+
+      if (parameter[1].constructor != Array)
+        parameter[1] = [parameter[1]];
+
+      return parameter[1].map(function(value) {
+        return key + '=' + encodeURIComponent(value);
+      }).join('&');
+    }
+  },
+
+  getValue: function(element) {
+    element = $(element);
+    var method = element.tagName.toLowerCase();
+    var parameter = Form.Element.Serializers[method](element);
+
+    if (parameter)
+      return parameter[1];
+  }
+}
+
+Form.Element.Serializers = {
+  input: function(element) {
+    switch (element.type.toLowerCase()) {
+      case 'submit':
+      case 'hidden':
+      case 'password':
+      case 'text':
+        return Form.Element.Serializers.textarea(element);
+      case 'checkbox':
+      case 'radio':
+        return Form.Element.Serializers.inputSelector(element);
+    }
+    return false;
+  },
+
+  inputSelector: function(element) {
+    if (element.checked)
+      return [element.name, element.value];
+  },
+
+  textarea: function(element) {
+    return [element.name, element.value];
+  },
+
+  select: function(element) {
+    return Form.Element.Serializers[element.type == 'select-one' ?
+      'selectOne' : 'selectMany'](element);
+  },
+
+  selectOne: function(element) {
+    var value = '', opt, index = element.selectedIndex;
+    if (index >= 0) {
+      opt = element.options[index];
+      value = opt.value;
+      if (!value && !('value' in opt))
+        value = opt.text;
+    }
+    return [element.name, value];
+  },
+
+  selectMany: function(element) {
+    var value = new Array();
+    for (var i = 0; i < element.length; i++) {
+      var opt = element.options[i];
+      if (opt.selected) {
+        var optValue = opt.value;
+        if (!optValue && !('value' in opt))
+          optValue = opt.text;
+        value.push(optValue);
+      }
+    }
+    return [element.name, value];
+  }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var $F = Form.Element.getValue;
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.TimedObserver = function() {}
+Abstract.TimedObserver.prototype = {
+  initialize: function(element, frequency, callback) {
+    this.frequency = frequency;
+    this.element   = $(element);
+    this.callback  = callback;
+
+    this.lastValue = this.getValue();
+    this.registerCallback();
+  },
+
+  registerCallback: function() {
+    setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+  },
+
+  onTimerEvent: function() {
+    var value = this.getValue();
+    if (this.lastValue != value) {
+      this.callback(this.element, value);
+      this.lastValue = value;
+    }
+  }
+}
+
+Form.Element.Observer = Class.create();
+Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
+  getValue: function() {
+    return Form.Element.getValue(this.element);
+  }
+});
+
+Form.Observer = Class.create();
+Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
+  getValue: function() {
+    return Form.serialize(this.element);
+  }
+});
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.EventObserver = function() {}
+Abstract.EventObserver.prototype = {
+  initialize: function(element, callback) {
+    this.element  = $(element);
+    this.callback = callback;
+
+    this.lastValue = this.getValue();
+    if (this.element.tagName.toLowerCase() == 'form')
+      this.registerFormCallbacks();
+    else
+      this.registerCallback(this.element);
+  },
+
+  onElementEvent: function() {
+    var value = this.getValue();
+    if (this.lastValue != value) {
+      this.callback(this.element, value);
+      this.lastValue = value;
+    }
+  },
+
+  registerFormCallbacks: function() {
+    var elements = Form.getElements(this.element);
+    for (var i = 0; i < elements.length; i++)
+      this.registerCallback(elements[i]);
+  },
+
+  registerCallback: function(element) {
+    if (element.type) {
+      switch (element.type.toLowerCase()) {
+        case 'checkbox':
+        case 'radio':
+          Event.observe(element, 'click', this.onElementEvent.bind(this));
+          break;
+        case 'password':
+        case 'text':
+        case 'textarea':
+        case 'select-one':
+        case 'select-multiple':
+          Event.observe(element, 'change', this.onElementEvent.bind(this));
+          break;
+      }
+    }
+  }
+}
+
+Form.Element.EventObserver = Class.create();
+Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
+  getValue: function() {
+    return Form.Element.getValue(this.element);
+  }
+});
+
+Form.EventObserver = Class.create();
+Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
+  getValue: function() {
+    return Form.serialize(this.element);
+  }
+});
+if (!window.Event) {
+  var Event = new Object();
+}
+
+Object.extend(Event, {
+  KEY_BACKSPACE: 8,
+  KEY_TAB:       9,
+  KEY_RETURN:   13,
+  KEY_ESC:      27,
+  KEY_LEFT:     37,
+  KEY_UP:       38,
+  KEY_RIGHT:    39,
+  KEY_DOWN:     40,
+  KEY_DELETE:   46,
+
+  element: function(event) {
+    return event.target || event.srcElement;
+  },
+
+  isLeftClick: function(event) {
+    return (((event.which) && (event.which == 1)) ||
+            ((event.button) && (event.button == 1)));
+  },
+
+  pointerX: function(event) {
+    return event.pageX || (event.clientX +
+      (document.documentElement.scrollLeft || document.body.scrollLeft));
+  },
+
+  pointerY: function(event) {
+    return event.pageY || (event.clientY +
+      (document.documentElement.scrollTop || document.body.scrollTop));
+  },
+
+  stop: function(event) {
+    if (event.preventDefault) {
+      event.preventDefault();
+      event.stopPropagation();
+    } else {
+      event.returnValue = false;
+      event.cancelBubble = true;
+    }
+  },
+
+  // find the first node with the given tagName, starting from the
+  // node the event was triggered on; traverses the DOM upwards
+  findElement: function(event, tagName) {
+    var element = Event.element(event);
+    while (element.parentNode && (!element.tagName ||
+        (element.tagName.toUpperCase() != tagName.toUpperCase())))
+      element = element.parentNode;
+    return element;
+  },
+
+  observers: false,
+
+  _observeAndCache: function(element, name, observer, useCapture) {
+    if (!this.observers) this.observers = [];
+    if (element.addEventListener) {
+      this.observers.push([element, name, observer, useCapture]);
+      element.addEventListener(name, observer, useCapture);
+    } else if (element.attachEvent) {
+      this.observers.push([element, name, observer, useCapture]);
+      element.attachEvent('on' + name, observer);
+    }
+  },
+
+  unloadCache: function() {
+    if (!Event.observers) return;
+    for (var i = 0; i < Event.observers.length; i++) {
+      Event.stopObserving.apply(this, Event.observers[i]);
+      Event.observers[i][0] = null;
+    }
+    Event.observers = false;
+  },
+
+  observe: function(element, name, observer, useCapture) {
+    var element = $(element);
+    useCapture = useCapture || false;
+
+    if (name == 'keypress' &&
+        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+        || element.attachEvent))
+      name = 'keydown';
+
+    this._observeAndCache(element, name, observer, useCapture);
+  },
+
+  stopObserving: function(element, name, observer, useCapture) {
+    var element = $(element);
+    useCapture = useCapture || false;
+
+    if (name == 'keypress' &&
+        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+        || element.detachEvent))
+      name = 'keydown';
+
+    if (element.removeEventListener) {
+      element.removeEventListener(name, observer, useCapture);
+    } else if (element.detachEvent) {
+      element.detachEvent('on' + name, observer);
+    }
+  }
+});
+
+/* prevent memory leaks in IE */
+Event.observe(window, 'unload', Event.unloadCache, false);
+var Position = {
+  // set to true if needed, warning: firefox performance problems
+  // NOT neeeded for page scrolling, only if draggable contained in
+  // scrollable elements
+  includeScrollOffsets: false,
+
+  // must be called before calling withinIncludingScrolloffset, every time the
+  // page is scrolled
+  prepare: function() {
+    this.deltaX =  window.pageXOffset
+                || document.documentElement.scrollLeft
+                || document.body.scrollLeft
+                || 0;
+    this.deltaY =  window.pageYOffset
+                || document.documentElement.scrollTop
+                || document.body.scrollTop
+                || 0;
+  },
+
+  realOffset: function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.scrollTop  || 0;
+      valueL += element.scrollLeft || 0;
+      element = element.parentNode;
+    } while (element);
+    return [valueL, valueT];
+  },
+
+  cumulativeOffset: function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+      element = element.offsetParent;
+    } while (element);
+    return [valueL, valueT];
+  },
+
+  positionedOffset: function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+      element = element.offsetParent;
+      if (element) {
+        p = Element.getStyle(element, 'position');
+        if (p == 'relative' || p == 'absolute') break;
+      }
+    } while (element);
+    return [valueL, valueT];
+  },
+
+  offsetParent: function(element) {
+    if (element.offsetParent) return element.offsetParent;
+    if (element == document.body) return element;
+
+    while ((element = element.parentNode) && element != document.body)
+      if (Element.getStyle(element, 'position') != 'static')
+        return element;
+
+    return document.body;
+  },
+
+  // caches x/y coordinate pair to use with overlap
+  within: function(element, x, y) {
+    if (this.includeScrollOffsets)
+      return this.withinIncludingScrolloffsets(element, x, y);
+    this.xcomp = x;
+    this.ycomp = y;
+    this.offset = this.cumulativeOffset(element);
+
+    return (y >= this.offset[1] &&
+            y <  this.offset[1] + element.offsetHeight &&
+            x >= this.offset[0] &&
+            x <  this.offset[0] + element.offsetWidth);
+  },
+
+  withinIncludingScrolloffsets: function(element, x, y) {
+    var offsetcache = this.realOffset(element);
+
+    this.xcomp = x + offsetcache[0] - this.deltaX;
+    this.ycomp = y + offsetcache[1] - this.deltaY;
+    this.offset = this.cumulativeOffset(element);
+
+    return (this.ycomp >= this.offset[1] &&
+            this.ycomp <  this.offset[1] + element.offsetHeight &&
+            this.xcomp >= this.offset[0] &&
+            this.xcomp <  this.offset[0] + element.offsetWidth);
+  },
+
+  // within must be called directly before
+  overlap: function(mode, element) {
+    if (!mode) return 0;
+    if (mode == 'vertical')
+      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
+        element.offsetHeight;
+    if (mode == 'horizontal')
+      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
+        element.offsetWidth;
+  },
+
+  clone: function(source, target) {
+    source = $(source);
+    target = $(target);
+    target.style.position = 'absolute';
+    var offsets = this.cumulativeOffset(source);
+    target.style.top    = offsets[1] + 'px';
+    target.style.left   = offsets[0] + 'px';
+    target.style.width  = source.offsetWidth + 'px';
+    target.style.height = source.offsetHeight + 'px';
+  },
+
+  page: function(forElement) {
+    var valueT = 0, valueL = 0;
+
+    var element = forElement;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+
+      // Safari fix
+      if (element.offsetParent==document.body)
+        if (Element.getStyle(element,'position')=='absolute') break;
+
+    } while (element = element.offsetParent);
+
+    element = forElement;
+    do {
+      valueT -= element.scrollTop  || 0;
+      valueL -= element.scrollLeft || 0;
+    } while (element = element.parentNode);
+
+    return [valueL, valueT];
+  },
+
+  clone: function(source, target) {
+    var options = Object.extend({
+      setLeft:    true,
+      setTop:     true,
+      setWidth:   true,
+      setHeight:  true,
+      offsetTop:  0,
+      offsetLeft: 0
+    }, arguments[2] || {})
+
+    // find page position of source
+    source = $(source);
+    var p = Position.page(source);
+
+    // find coordinate system to use
+    target = $(target);
+    var delta = [0, 0];
+    var parent = null;
+    // delta [0,0] will do fine with position: fixed elements,
+    // position:absolute needs offsetParent deltas
+    if (Element.getStyle(target,'position') == 'absolute') {
+      parent = Position.offsetParent(target);
+      delta = Position.page(parent);
+    }
+
+    // correct by body offsets (fixes Safari)
+    if (parent == document.body) {
+      delta[0] -= document.body.offsetLeft;
+      delta[1] -= document.body.offsetTop;
+    }
+
+    // set position
+    if(options.setLeft)   target.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
+    if(options.setTop)    target.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
+    if(options.setWidth)  target.style.width = source.offsetWidth + 'px';
+    if(options.setHeight) target.style.height = source.offsetHeight + 'px';
+  },
+
+  absolutize: function(element) {
+    element = $(element);
+    if (element.style.position == 'absolute') return;
+    Position.prepare();
+
+    var offsets = Position.positionedOffset(element);
+    var top     = offsets[1];
+    var left    = offsets[0];
+    var width   = element.clientWidth;
+    var height  = element.clientHeight;
+
+    element._originalLeft   = left - parseFloat(element.style.left  || 0);
+    element._originalTop    = top  - parseFloat(element.style.top || 0);
+    element._originalWidth  = element.style.width;
+    element._originalHeight = element.style.height;
+
+    element.style.position = 'absolute';
+    element.style.top    = top + 'px';;
+    element.style.left   = left + 'px';;
+    element.style.width  = width + 'px';;
+    element.style.height = height + 'px';;
+  },
+
+  relativize: function(element) {
+    element = $(element);
+    if (element.style.position == 'relative') return;
+    Position.prepare();
+
+    element.style.position = 'relative';
+    var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
+    var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
+
+    element.style.top    = top + 'px';
+    element.style.left   = left + 'px';
+    element.style.height = element._originalHeight;
+    element.style.width  = element._originalWidth;
+  }
+}
+
+// Safari returns margins on body which is incorrect if the child is absolutely
+// positioned.  For performance reasons, redefine Position.cumulativeOffset for
+// KHTML/WebKit only.
+if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
+  Position.cumulativeOffset = function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+      if (element.offsetParent == document.body)
+        if (Element.getStyle(element, 'position') == 'absolute') break;
+
+      element = element.offsetParent;
+    } while (element);
+
+    return [valueL, valueT];
+  }
+}
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/stylesheets/default.css b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/stylesheets/default.css
new file mode 100755
index 0000000..4690799
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/stylesheets/default.css
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+body {
+    background: #5c8098 url(../images/body-background.png) repeat-x;
+}
+
+html, body, h1, h2 {
+    margin: 0;
+    padding: 0;
+}
+
+body, textarea, input {
+    font-size: 12px;
+    font-family: Verdana, Helvetica, Arial, sans-serif;
+    color: #2d2b3d;
+}
+
+#container {
+    text-align: center;
+}
+
+#container-inner {
+    margin-left: auto;
+    margin-right: auto;
+    text-align: justify;
+    width: 820px;
+}
+
+#header {
+    width: 820px;
+    height: 100px;
+    background: url(../images/header-background.png) no-repeat;
+}
+
+#header h1 {
+    display: none;
+}
+
+#main {
+    height: 610px;
+    background: url(../images/main-background.png) no-repeat;
+    text-align: left;
+    width: 740px;
+    padding: 30px 40px 20px 40px;
+}
+
+#display {
+    border: 1px solid #5c8098;
+    width: 740px;
+    height: 400px;
+    margin-bottom: 10px;
+    overflow-y: scroll;
+}
+
+#login-name {
+    width: 200px;
+}
+
+#message {
+    width: 740px;
+    height: 50px;
+}
+
+#missing-sockets {
+    color: red;
+    font-size: xx-large;
+    display: none;
+}
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/test.html b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/test.html
new file mode 100644
index 0000000..88d7fef
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/main/webapp/test.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<head>
+   <title>WebSockets Ping</title>
+ <script>
+// core init of the "framework"
+ws = new WebSocket("ws://192.168.1.100:8080/grizzly-websockets-chat");
+ws.onmessage = function(evt)
+{
+ var pTag = document.createElement("p");
+ var text = document.createTextNode(evt.data);
+ pTag.appendChild(text);
+ document.getElementById('content').appendChild(pTag);
+};
+ws.onclose = function()
+{
+ alert("socket closed");
+};
+</script>
+
diff --git a/appserver/tests/embedded/maven-plugin/websockets/src/test/java/org/glassfish/tests/standalonewar/WebTest.java b/appserver/tests/embedded/maven-plugin/websockets/src/test/java/org/glassfish/tests/standalonewar/WebTest.java
new file mode 100644
index 0000000..f72a6af
--- /dev/null
+++ b/appserver/tests/embedded/maven-plugin/websockets/src/test/java/org/glassfish/tests/standalonewar/WebTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.standalonewar;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class WebTest {
+        
+    private static int count = 0;
+    private static int EXPECTED_COUNT = 3;
+
+    private String contextPath = "test";
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        goGet("localhost", 8080, "Please input your name", contextPath);
+    }
+
+    private static void goGet(String host, int port,
+                              String result, String contextPath) throws Exception {
+        try {
+            URL servlet = new URL("http://localhost:8080/test");
+            URLConnection yc = servlet.openConnection();
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    yc.getInputStream()));
+            String line = null;
+            int index;
+            while ((line = in.readLine()) != null) {
+                index = line.indexOf(result);
+                if (index != -1) {
+                    index = line.indexOf(":");
+                    String status = line.substring(index+1);
+
+                    if (status.equalsIgnoreCase("PASS")){
+                        count++;
+                    } else {
+                        return;
+                    }
+                }
+            }
+            Assert.assertTrue(count==3);
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+   }
+
+}
diff --git a/appserver/tests/embedded/mysql/pom.xml b/appserver/tests/embedded/mysql/pom.xml
new file mode 100644
index 0000000..bc6d55b
--- /dev/null
+++ b/appserver/tests/embedded/mysql/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>mysql</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <packaging>war</packaging>
+    <name>Simple web application which uses mysql as database</name>
+    <build>
+        <finalName>mysqltest</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <skip>false</skip>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.main.extras</groupId>
+            <artifactId>glassfish-embedded-all</artifactId>
+            <version>5.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.15</version>
+        </dependency>
+        <dependency>
+            <groupId>com.mysql.connector</groupId>
+            <artifactId>mxj</artifactId>
+            <version>${project.version}</version>
+            <scope>system</scope>
+            <systemPath>/tmp/mysql-connector-mxj-gpl-5-0-11/mysql-connector-mxj-gpl-5-0-11.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>com.mysql.connector</groupId>
+            <artifactId>mxj-db-files</artifactId>
+            <version>${project.version}</version>
+            <scope>system</scope>
+            <systemPath>/tmp/mysql-connector-mxj-gpl-5-0-11/mysql-connector-mxj-gpl-5-0-11-db-files.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/tests/embedded/mysql/src/main/java/org/glassfish/tests/embedded/web/MySqlTestServlet.java b/appserver/tests/embedded/mysql/src/main/java/org/glassfish/tests/embedded/web/MySqlTestServlet.java
new file mode 100644
index 0000000..8b9e44a
--- /dev/null
+++ b/appserver/tests/embedded/mysql/src/main/java/org/glassfish/tests/embedded/web/MySqlTestServlet.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import javax.annotation.Resource;
+import javax.annotation.sql.DataSourceDefinition;
+import javax.annotation.sql.DataSourceDefinitions;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+import javax.transaction.UserTransaction;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+@DataSourceDefinitions({
+@DataSourceDefinition(name = "java:app/mysql/MySQLDataSource",
+        className = "com.mysql.jdbc.jdbc2.optional.MysqlDataSource",
+        portNumber = 3306,
+        serverName = "localhost",
+        databaseName = "testDB",
+        user = "root",
+        password = "abc123",
+        properties = {"createDatabaseIfNotExist=true"}),
+@DataSourceDefinition(name = "java:app/mysql/MySQLEmbeddedDataSource",
+        className = "com.mysql.jdbc.Driver",
+        url="jdbc:mysql:mxj://localhost:3336/testDB",
+        user = "root",
+        password = "abc123",
+        properties = {"createDatabaseIfNotExist=true",
+                "server.basedir=/tmp/testDB", "server.initialize-user=true"})
+})
+@WebServlet(name = "mySqlTestServlet", urlPatterns = "/mysqlTestServlet")
+public class MySqlTestServlet extends HttpServlet {
+
+    @Resource(mappedName = "java:app/mysql/MySQLDataSource")
+    DataSource myDB;
+
+    @Resource(mappedName = "java:app/mysql/MySQLEmbeddedDataSource")
+    DataSource myEmbeddedDB;
+
+    @PersistenceContext
+    private EntityManager em;
+
+    @Resource
+    private UserTransaction utx;
+
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter writer = httpServletResponse.getWriter();
+        try {
+            writer.println("DS = " + myDB);
+            writer.println("EM = " + em);
+            Connection connection = myEmbeddedDB.getConnection();
+            writer.println("connection = " + connection);
+            connection.close();
+
+            if (!entryExists("BHAVANI-13-02")) {
+                Person person = new Person("BHAVANI-13-02", "Bhavanishankar", "Engineer");
+                utx.begin();
+                em.persist(person);
+                utx.commit();
+                System.out.println("Persisted " + person);
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace(writer);
+        } finally {
+            writer.flush();
+            writer.close();
+        }
+    }
+
+    private boolean entryExists(String uuid) {
+        return em.find(Person.class, uuid) != null;
+    }
+
+}
diff --git a/appserver/tests/embedded/mysql/src/main/java/org/glassfish/tests/embedded/web/Person.java b/appserver/tests/embedded/mysql/src/main/java/org/glassfish/tests/embedded/web/Person.java
new file mode 100644
index 0000000..c1e1cdd
--- /dev/null
+++ b/appserver/tests/embedded/mysql/src/main/java/org/glassfish/tests/embedded/web/Person.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+@Entity
+@Table(name = "person")
+public class Person {
+
+    @Id
+    @Column(name = "UUID")
+    private String uuid;
+
+    @Column(name = "NAME")
+    private String name;
+
+    @Column(name = "PROFESSION")
+    private String profession;
+
+    public Person() {}
+    
+    public Person(String uuid, String name, String profession) {
+        setUuid(uuid);
+        setName(name);
+        setProfession(profession);
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getProfession() {
+        return profession;
+    }
+
+    public void setProfession(String profession) {
+        this.profession = profession;
+    }
+
+    @Override
+    public String toString() {
+        return "Person [uuid = " + uuid + ", name = " + name +
+                ", profession = " + profession + "]";
+    }
+}
diff --git a/appserver/tests/embedded/mysql/src/main/resources/META-INF/persistence.xml b/appserver/tests/embedded/mysql/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..54cb06c
--- /dev/null
+++ b/appserver/tests/embedded/mysql/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+    <persistence-unit name="mysql_testdb" transaction-type="JTA">
+        <jta-data-source>java:app/mysql/MySQLEmbeddedDataSource</jta-data-source>
+        <properties>
+            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+            <property name="eclipselink.logging.level" value="FINE"/>
+        </properties>
+    </persistence-unit>
+</persistence>
diff --git a/appserver/tests/embedded/mysql/src/test/java/org/glassfish/tests/embedded/web/MySqlTest.java b/appserver/tests/embedded/mysql/src/test/java/org/glassfish/tests/embedded/web/MySqlTest.java
new file mode 100644
index 0000000..70d6a4d
--- /dev/null
+++ b/appserver/tests/embedded/mysql/src/test/java/org/glassfish/tests/embedded/web/MySqlTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishProperties;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.junit.*;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+public class MySqlTest {
+
+    @Test
+    public void test() throws Exception {
+        GlassFishProperties glassFishProperties = new GlassFishProperties();
+        glassFishProperties.setPort("http-listener", 8080);
+
+        GlassFish glassFish = GlassFishRuntime.bootstrap().
+                newGlassFish(glassFishProperties);
+
+        glassFish.start();
+
+        Deployer deployer = glassFish.getDeployer();
+        String appName = deployer.deploy(new File("target/mysqltest.war"));
+        System.out.println("Deployed [" + appName + "]");
+
+
+        // Access the app
+        get("http://localhost:8080/mysqltest/mysqlTestServlet", "connection = ");
+
+        glassFish.dispose();
+
+    }
+
+    private static void get(String url, String result) throws Exception {
+        try {
+            URL servlet = new URL(url);
+            HttpURLConnection uc = (HttpURLConnection) servlet.openConnection();
+            System.out.println("\nURLConnection = " + uc + " : ");
+            if (uc.getResponseCode() != 200) {
+                throw new Exception("Servlet did not return 200 OK response code");
+            }
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    uc.getInputStream()));
+            String line = null;
+            boolean found = false;
+            int index;
+            while ((line = in.readLine()) != null) {
+                System.out.println(line);
+                index = line.indexOf(result);
+                if (index != -1) {
+                    found = true;
+                }
+            }
+            Assert.assertTrue(found);
+            System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+            in.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+}
diff --git a/appserver/tests/embedded/pom.xml b/appserver/tests/embedded/pom.xml
new file mode 100755
index 0000000..53b1cc3
--- /dev/null
+++ b/appserver/tests/embedded/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests</groupId>
+    <artifactId>embedded</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>GlassFish Embedded Tests</name>  
+
+    <modules>
+    	<module>basic</module>
+    	<module>cdi_basic</module>
+    	<module>cdi_ejb_jpa</module>
+    	<module>glassfish_resources_xml</module>
+    	<module>ejb</module>
+    	<module>scatteredarchive</module>
+        <module>maven-plugin</module>
+        <module>web</module>
+    </modules>
+</project>
diff --git a/appserver/tests/embedded/run_test.sh b/appserver/tests/embedded/run_test.sh
new file mode 100755
index 0000000..f81e223
--- /dev/null
+++ b/appserver/tests/embedded/run_test.sh
@@ -0,0 +1,86 @@
+#!/bin/bash -ex
+#
+# Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0, which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# This Source Code may also be made available under the following Secondary
+# Licenses when the conditions for such availability set forth in the
+# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+# version 2 with the GNU Classpath Exception, which is available at
+# https://www.gnu.org/software/classpath/license.html.
+#
+# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+#
+
+test_run_embedded(){
+	MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=384m"; export MAVEN_OPTS
+	MAVEN_REPO=$WORKSPACE/repository
+	PATH=$JAVA_HOME/bin:$PATH; export PATH
+	echo $WORKSPACE
+  cd $WORKSPACE/main
+  mvn -Dmaven.repo.local=$WORKSPACE/repository -DskipTests=true clean install
+  EMBEDDED_WORKSPACE=$WORKSPACE/main/appserver/extras/embedded
+  cd $EMBEDDED_WORKSPACE/all
+  mvn -Dmaven.repo.local=$WORKSPACE/repository -DskipTests=true clean install
+  cd $EMBEDDED_WORKSPACE/nucleus
+  mvn -Dmaven.repo.local=$WORKSPACE/repository -DskipTests=true clean install
+  cd $EMBEDDED_WORKSPACE/web
+  mvn -Dmaven.repo.local=$WORKSPACE/repository -DskipTests=true clean install
+  cd $WORKSPACE/main/appserver/tests/embedded/maven-plugin/remoteejbs
+  mvn -Dmaven.repo.local=$WORKSPACE/repository -DskipTests=true clean verify
+  cd $WORKSPACE/main/appserver/tests/embedded/maven-plugin/mdb
+  mvn -Dmaven.repo.local=$WORKSPACE/repository -DskipTests=true clean verify
+  cd $WORKSPACE/main/appserver/tests/embedded
+  mvn -Dbuild=snapshot  -Dmaven.repo.local=$WORKSPACE/repository -Dmaven.test.failure.ignore=true clean verify
+  merge_junits
+}
+
+merge_junits(){
+  TEST_ID="embedded_all"
+  rm -rf ${WORKSPACE}/results || true
+  mkdir -p ${WORKSPACE}/results/junitreports
+  JUD="${WORKSPACE}/results/junitreports/test_results_junit.xml"
+  echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > ${JUD}
+  echo "<testsuites>" >> ${JUD}
+  for i in `find . -type d -name "surefire-reports"`
+  do    
+    ls -d -1 ${i}/*.xml | xargs cat | ${SED} 's/<?xml version=\"1.0\" encoding=\"UTF-8\" *?>//g' >> ${JUD}
+  done
+  echo "</testsuites>" >> ${JUD}
+  ${SED} -i 's/\([a-zA-Z-]\w*\)\./\1-/g' ${JUD}
+  ${SED} -i "s/\bclassname=\"/classname=\"${TEST_ID}./g" ${JUD}
+}
+
+run_test_id(){
+	source `dirname $0`/../common_test.sh
+	kill_process
+	rm main.zip rm version-info.txt || true
+	download_test_resources main.zip version-info.txt
+	rm -rf main || true
+	unzip_test_resources "$WORKSPACE/bundles/main.zip -d main/"
+  case ${TEST_ID} in
+    embedded_all)
+   	  test_run_embedded;;
+  esac
+  upload_test_results
+  delete_bundle
+
+}
+
+
+list_test_ids(){
+	echo embedded_all
+}
+
+OPT=$1
+TEST_ID=$2
+
+case $OPT in
+	list_test_ids )
+		list_test_ids;;
+	run_test_id )
+		run_test_id $TEST_ID ;;
+esac
diff --git a/appserver/tests/embedded/scatteredarchive/pom.xml b/appserver/tests/embedded/scatteredarchive/pom.xml
new file mode 100644
index 0000000..66d8a13
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.basic</groupId>
+    <artifactId>scatteredarchive</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Scattered Archive Test</name>
+    <build>
+	<finalName>scatteredarchive</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <forkMode>always</forkMode>
+		    <useSystemClassLoader>false</useSystemClassLoader>
+		    <useManifestOnlyJar>false</useManifestOnlyJar>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+	<profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>	
+	<dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+        </dependency>
+    </dependencies>    
+</project>
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/config/application.xml b/appserver/tests/embedded/scatteredarchive/src/main/config/application.xml
new file mode 100755
index 0000000..49d7d48
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/config/application.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN'
+        'http://java.sun.com/dtd/application_1_3.dtd'>
+
+<application>
+
+    <display-name>Scattered Enterprise Archive Test</display-name>
+
+    <description>Scattered Enterprise Archive</description>
+
+    <module>
+        <web>
+            <web-uri>sa.war</web-uri>
+            <context-root>satest</context-root>
+        </web>
+    </module>
+
+    <module>
+        <connector>scatteredra.rar</connector>
+    </module>
+</application>
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/config/ra.xml b/appserver/tests/embedded/scatteredarchive/src/main/config/ra.xml
new file mode 100644
index 0000000..0ac1794
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/config/ra.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           version="1.5">
+
+    <display-name>Scattered Archive Test RA</display-name>
+    <vendor-name>Oracle Corporation</vendor-name>
+    <eis-type>ScatteredArchiveTestRA</eis-type>
+    <resourceadapter-version>1.0</resourceadapter-version>
+
+    <resourceadapter>
+
+        <resourceadapter-class>
+            org.glassfish.tests.embedded.scatteredarchive.ScatteredArchiveTestRA
+        </resourceadapter-class>
+    </resourceadapter>
+
+
+</connector>
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTestRA.java b/appserver/tests/embedded/scatteredarchive/src/main/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTestRA.java
new file mode 100644
index 0000000..e01a8be
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTestRA.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.scatteredarchive;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.xa.XAResource;
+import java.util.logging.Logger;
+
+/**
+ * @author bhavanishankar@java.net
+ */
+
+public class ScatteredArchiveTestRA implements ResourceAdapter {
+
+    private static final Logger logger = Logger.getAnonymousLogger();
+
+    public void start(BootstrapContext bootstrapContext)
+            throws ResourceAdapterInternalException {
+        logger.info("ScatteredArchiveTestRA start has been called");
+    }
+
+    public void stop() {
+        logger.info("ScatteredArchiveTestRA stop has been called");
+    }
+
+    public void endpointActivation(MessageEndpointFactory messageEndpointFactory,
+                                   ActivationSpec activationSpec) throws ResourceException {
+        logger.info("ScatteredArchiveTestRA endpointActivation has been called");
+    }
+
+    public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory,
+                                     ActivationSpec activationSpec) {
+        logger.info("ScatteredArchiveTestRA endpointDeactivation has been called");
+    }
+
+    public XAResource[] getXAResources(ActivationSpec[] activationSpecs)
+            throws ResourceException {
+        logger.info("ScatteredArchiveTestRA getXAResources has been called");
+        return new XAResource[0];
+    }
+}
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTestServlet.java b/appserver/tests/embedded/scatteredarchive/src/main/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTestServlet.java
new file mode 100644
index 0000000..a6be25b
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTestServlet.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.scatteredarchive;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+@WebServlet(name = "ScatteredArchiveTestServlet",
+        urlPatterns = "/ScatteredArchiveTestServlet")
+public class ScatteredArchiveTestServlet extends HttpServlet {
+    
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+        out.println("Hi from ScatteredArchiveTestServlet");
+        out.flush();
+        out.close();
+    }
+}
+
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/resources/LocalStrings.properties b/appserver/tests/embedded/scatteredarchive/src/main/resources/LocalStrings.properties
new file mode 100644
index 0000000..38bb205
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/resources/LocalStrings.properties
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v. 2.0, which is available at
+# http://www.eclipse.org/legal/epl-2.0.
+#
+# This Source Code may also be made available under the following Secondary
+# Licenses when the conditions for such availability set forth in the
+# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+# version 2 with the GNU Classpath Exception, which is available at
+# https://www.gnu.org/software/classpath/license.html.
+#
+# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+#
+
+greeting_message=Hi, my name is Bhavani. What's yours?
+greeting_response=Hello
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/scatteredarchive/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..bf9a1e2
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>/satest</context-root> 
+</sun-web-app>
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/scatteredarchive/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..ace5297
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+  <display-name>jsptest</display-name>  
+  <distributable/>
+</web-app>
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/webapp/images/duke.waving.gif b/appserver/tests/embedded/scatteredarchive/src/main/webapp/images/duke.waving.gif
new file mode 100644
index 0000000..4336a2d
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/webapp/images/duke.waving.gif
Binary files differ
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/webapp/index.jsp b/appserver/tests/embedded/scatteredarchive/src/main/webapp/index.jsp
new file mode 100644
index 0000000..a1b427e
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/webapp/index.jsp
@@ -0,0 +1,44 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+
+<html>
+<head><title>Hello</title></head>
+<body bgcolor="white">
+<img src="images/duke.waving.gif"> 
+
+<fmt:requestEncoding value="UTF-8"/>
+
+<fmt:setBundle basename="LocalStrings" var="resourceBundle" scope="page"/>
+
+<h2><fmt:message key="greeting_message" bundle="${resourceBundle}"/></h2>
+<form method="get">
+<input type="text" name="username" size="25">
+<p></p>
+<input type="submit" value="Submit">
+<input type="reset" value="Reset">
+</form>
+
+<c:if test="${not empty param['username']}">
+    <%@include file="response.jsp" %>
+</c:if>
+
+</body>
+</html>
diff --git a/appserver/tests/embedded/scatteredarchive/src/main/webapp/response.jsp b/appserver/tests/embedded/scatteredarchive/src/main/webapp/response.jsp
new file mode 100644
index 0000000..09a6de7
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/main/webapp/response.jsp
@@ -0,0 +1,50 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+
+<%@ page import="javax.servlet.http.*" %>
+
+<%
+    String user = (String)request.getParameter("username");
+    HttpSession httpSession = request.getSession();
+    String users = (String)httpSession.getAttribute("users");
+    if ( users == null ) {
+	users = user;
+    }
+    else {
+	users = users + ", " + user;
+    }
+    httpSession.setAttribute("users", users);
+%>
+
+
+<h2><font color="black"><fmt:message key="greeting_response" bundle="${resourceBundle}"/>, <%= users %>!</font></h2>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/appserver/tests/embedded/scatteredarchive/src/test/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTest.java b/appserver/tests/embedded/scatteredarchive/src/test/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTest.java
new file mode 100644
index 0000000..30b1877
--- /dev/null
+++ b/appserver/tests/embedded/scatteredarchive/src/test/java/org/glassfish/tests/embedded/scatteredarchive/ScatteredArchiveTest.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.scatteredarchive;
+
+import junit.framework.Assert;
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishProperties;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.glassfish.embeddable.archive.ScatteredArchive;
+import org.glassfish.embeddable.archive.ScatteredEnterpriseArchive;
+import org.glassfish.embeddable.web.HttpListener;
+import org.glassfish.embeddable.web.WebContainer;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class ScatteredArchiveTest {
+
+    @Test
+    public void test() throws Exception {
+
+        GlassFishProperties props = new GlassFishProperties();
+        props.setPort("http-listener", 8080);
+        GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(props);
+        glassfish.start();
+
+        // Test Scattered Web Archive
+        ScatteredArchive sa = new ScatteredArchive("scatteredarchive",
+                ScatteredArchive.Type.WAR, new File("src/main/webapp"));
+        sa.addClassPath(new File("target/classes"));
+        sa.addClassPath(new File("src/main/resources"));
+        URI warURI = sa.toURI();
+        printContents(warURI);
+
+        // Deploy archive
+        Deployer deployer = glassfish.getDeployer();
+        String appname = deployer.deploy(warURI);
+        System.out.println("Deployed [" + appname + "]");
+        Assert.assertEquals(appname, "scatteredarchive");
+
+        // Now create a http listener and access the app.
+        WebContainer webcontainer = glassfish.getService(WebContainer.class);
+        HttpListener listener = new HttpListener();
+        listener.setId("my-listener");
+        listener.setPort(9090);
+        webcontainer.addWebListener(listener);
+
+        get("http://localhost:9090/satest", "Hi, my name is Bhavani. What's yours?");
+        get("http://localhost:9090/satest/ScatteredArchiveTestServlet",
+                "Hi from ScatteredArchiveTestServlet");
+        get("http://localhost:8080/satest/ScatteredArchiveTestServlet",
+                "Hi from ScatteredArchiveTestServlet");
+
+        deployer.undeploy(appname);
+
+        // Test Scattered RA
+        ScatteredArchive rar = new ScatteredArchive("scatteredra",
+                ScatteredArchive.Type.RAR);
+        rar.addClassPath(new File("target/classes"));
+        rar.addMetadata(new File("src/main/config/ra.xml"));
+        URI rarURI = rar.toURI();
+        printContents(rarURI);
+        appname = deployer.deploy(rarURI);
+        System.out.println("Deployed RAR [" + appname + "]");
+        Assert.assertEquals(appname, "scatteredra");
+
+        // Test Scattered Enterprise Archive.
+        ScatteredEnterpriseArchive ear = new ScatteredEnterpriseArchive("sear");
+        ear.addArchive(warURI, "sa.war");
+        ear.addArchive(rarURI);
+        ear.addMetadata(new File("src/main/config/application.xml"));
+        URI earURI = ear.toURI();
+        printContents(earURI);
+        appname = deployer.deploy(earURI);
+        System.out.println("Deployed [" + appname + "]");
+        Assert.assertEquals(appname, "sear");
+
+        get("http://localhost:9090/satest", "Hi, my name is Bhavani. What's yours?");
+        get("http://localhost:9090/satest/ScatteredArchiveTestServlet",
+                "Hi from ScatteredArchiveTestServlet");
+        get("http://localhost:8080/satest/ScatteredArchiveTestServlet",
+                "Hi from ScatteredArchiveTestServlet");
+
+        glassfish.dispose();
+
+    }
+
+    private void get(String urlStr, String result) throws Exception {
+        URL url = new URL(urlStr);
+        URLConnection yc = url.openConnection();
+        System.out.println("\nURLConnection [" + yc + "] : ");
+        BufferedReader in = new BufferedReader(new InputStreamReader(
+                yc.getInputStream()));
+        String line = null;
+        boolean found = false;
+        while ((line = in.readLine()) != null) {
+            System.out.println(line);
+            if (line.indexOf(result) != -1) {
+                found = true;
+            }
+        }
+        Assert.assertTrue(found);
+        System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+    }
+
+    void printContents(URI jarURI) throws IOException {
+        JarFile jarfile = new JarFile(new File(jarURI));
+        System.out.println("\n\n[" + jarURI + "] contents : \n");
+        Enumeration<JarEntry> entries = jarfile.entries();
+        while (entries.hasMoreElements()) {
+            JarEntry entry = entries.nextElement();
+            System.out.println(entry.getSize() + "\t" + new Date(entry.getTime()) +
+                    "\t" + entry.getName());
+        }
+        System.out.println();
+    }
+}
diff --git a/appserver/tests/embedded/servlet_runs_admin_cmds/pom.xml b/appserver/tests/embedded/servlet_runs_admin_cmds/pom.xml
new file mode 100644
index 0000000..c750158
--- /dev/null
+++ b/appserver/tests/embedded/servlet_runs_admin_cmds/pom.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.basic</groupId>
+    <artifactId>servlet_runs_admin_cmds</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Servlet Running Admin Commands using org.glassfish.embeddable.CommandRunner</name>
+    <packaging>war</packaging>
+    <build>
+	<finalName>servlet_runs_admin_cmds</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <skip>false</skip>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+	<profiles>
+        <profile>
+            <id>run-with-3.1.1</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>3.1.1</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>	
+	<dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.main.common</groupId>
+            <artifactId>simple-glassfish-api</artifactId>
+            <version>3.1.1</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>4.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>    
+
+</project>
diff --git a/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/java/org/glassfish/tests/embedded/servlet_runs_admin_cmds/RunAdminCommandsServlet.java b/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/java/org/glassfish/tests/embedded/servlet_runs_admin_cmds/RunAdminCommandsServlet.java
new file mode 100644
index 0000000..b9814ef
--- /dev/null
+++ b/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/java/org/glassfish/tests/embedded/servlet_runs_admin_cmds/RunAdminCommandsServlet.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.servlet_runs_admin_cmds;
+
+import org.glassfish.embeddable.CommandResult;
+import org.glassfish.embeddable.CommandRunner;
+
+import javax.annotation.Resource;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+@WebServlet(name = "RunAdminCommandsServlet",
+        urlPatterns = "/RunAdminCommandsServlet")
+public class RunAdminCommandsServlet extends HttpServlet {
+
+    @Resource(mappedName = "org.glassfish.embeddable.CommandRunner")
+    CommandRunner cr;
+
+    @Override
+    protected void doGet(HttpServletRequest httpServletRequest,
+                         HttpServletResponse httpServletResponse) throws ServletException, IOException {
+        PrintWriter out = httpServletResponse.getWriter();
+        out.println("Inside RunAdminCommandsServlet...");
+        out.println("CommandRunner = " + cr);
+        if (cr != null) {
+            CommandResult result = cr.run("create-jdbc-connection-pool",
+                    "--datasourceclassname=org.apache.derby.jdbc.ClientDataSource",
+                    "--restype=javax.sql.XADataSource",
+                    "--property=portNumber=1527:password=APP:user=APP:serverName=localhost:databaseName=sun-appserv-samples:connectionAttributes=create\\=true",
+                    "sample_derby_pool");
+            out.println("Ran create-jdbc-connection-pool command. Output = [ " +
+                    result.getOutput() + "]");
+            result = cr.run("version");
+            out.println("Ran version command. Output = [" + result.getOutput() + "]");
+        }
+        out.flush();
+        out.close();
+    }
+}
+
diff --git a/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/webapp/WEB-INF/sun-web.xml b/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/webapp/WEB-INF/sun-web.xml
new file mode 100644
index 0000000..d5df258
--- /dev/null
+++ b/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/webapp/WEB-INF/sun-web.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
+<sun-web-app>
+  <context-root>/servlet_runs_admin_cmds</context-root>
+</sun-web-app>
diff --git a/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..f1b64fd
--- /dev/null
+++ b/appserver/tests/embedded/servlet_runs_admin_cmds/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+    <display-name>servlet_runs_admin_cmds</display-name>
+    <distributable/>
+    <welcome-file-list>
+        <welcome-file>RunAdminCommandsServlet</welcome-file>
+    </welcome-file-list>
+</web-app>
diff --git a/appserver/tests/embedded/servlet_runs_admin_cmds/src/test/java/org/glassfish/tests/embedded/servlet_runs_admin_cmds/RunAdminCommandsTest.java b/appserver/tests/embedded/servlet_runs_admin_cmds/src/test/java/org/glassfish/tests/embedded/servlet_runs_admin_cmds/RunAdminCommandsTest.java
new file mode 100644
index 0000000..23f5b15
--- /dev/null
+++ b/appserver/tests/embedded/servlet_runs_admin_cmds/src/test/java/org/glassfish/tests/embedded/servlet_runs_admin_cmds/RunAdminCommandsTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.servlet_runs_admin_cmds;
+
+import junit.framework.Assert;
+import org.glassfish.embeddable.CommandRunner;
+import org.glassfish.embeddable.Deployer;
+import org.glassfish.embeddable.GlassFish;
+import org.glassfish.embeddable.GlassFishProperties;
+import org.glassfish.embeddable.GlassFishRuntime;
+import org.junit.Test;
+
+import javax.naming.InitialContext;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * @author bhavanishankar@dev.java.net
+ */
+
+public class RunAdminCommandsTest {
+
+    @Test
+    public void test() throws Exception {
+
+        GlassFishProperties props = new GlassFishProperties();
+        props.setPort("http-listener", 9090);
+        GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(props);
+        glassfish.start();
+
+        // Bind the command runner in JNDI tree with your own mapped-name.
+        CommandRunner cr = glassfish.getCommandRunner();
+        new InitialContext().bind("org.glassfish.embeddable.CommandRunner", cr);
+
+        // Deploy archive
+        Deployer deployer = glassfish.getDeployer();
+        String appname = deployer.deploy(new File("target/servlet_runs_admin_cmds.war"));
+        System.out.println("Deployed [" + appname + "]");
+        Assert.assertEquals(appname, "servlet_runs_admin_cmds");
+
+        get("http://localhost:9090/servlet_runs_admin_cmds",
+                "JDBC connection pool sample_derby_pool created successfully");
+
+        deployer.undeploy(appname);
+        glassfish.dispose();
+    }
+
+    private void get(String urlStr, String result) throws Exception {
+        URL url = new URL(urlStr);
+        URLConnection yc = url.openConnection();
+        System.out.println("\nURLConnection [" + yc + "] : ");
+        BufferedReader in = new BufferedReader(new InputStreamReader(
+                yc.getInputStream()));
+        String line = null;
+        boolean found = false;
+        while ((line = in.readLine()) != null) {
+            System.out.println(line);
+            if (line.indexOf(result) != -1) {
+                found = true;
+            }
+        }
+        Assert.assertTrue(found);
+        System.out.println("\n***** SUCCESS **** Found [" + result + "] in the response.*****\n");
+    }
+
+}
diff --git a/appserver/tests/embedded/static-ejb/.gitkeep_empty_dir b/appserver/tests/embedded/static-ejb/.gitkeep_empty_dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/appserver/tests/embedded/static-ejb/.gitkeep_empty_dir
diff --git a/appserver/tests/embedded/static/ejb/pom.xml b/appserver/tests/embedded/static/ejb/pom.xml
new file mode 100755
index 0000000..17ea6f9
--- /dev/null
+++ b/appserver/tests/embedded/static/ejb/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>static</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <groupId>org.glassfish.tests.embedded.static</groupId>
+    <artifactId>ejb</artifactId>
+    <packaging>pom</packaging>
+    <name>GlassFish Static Embedded EJB Tests</name>  
+    <modules>
+    	<module>simple</module>
+    </modules>
+</project>
diff --git a/appserver/tests/embedded/static/ejb/simple/pom.xml b/appserver/tests/embedded/static/ejb/simple/pom.xml
new file mode 100644
index 0000000..6d1c341
--- /dev/null
+++ b/appserver/tests/embedded/static/ejb/simple/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.glassfish.tests.embedded.static</groupId>
+        <artifactId>ejb</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded.static.ejb</groupId>
+    <artifactId>simple</artifactId>
+	<name>EJB static simple test</name>
+    <dependencies>
+        <dependency>
+            <groupId>javax.ejb</groupId>
+            <artifactId>javax.ejb-api</artifactId>
+            <version>3.2-b01</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.extras</groupId>
+            <artifactId>glassfish-embedded-web</artifactId>
+            <version>5.0.1-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/tests/embedded/static/ejb/simple/src/main/java/org/glassfish/tests/embedded/ejb/SampleEjb.java b/appserver/tests/embedded/static/ejb/simple/src/main/java/org/glassfish/tests/embedded/ejb/SampleEjb.java
new file mode 100644
index 0000000..fa168aa
--- /dev/null
+++ b/appserver/tests/embedded/static/ejb/simple/src/main/java/org/glassfish/tests/embedded/ejb/SampleEjb.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb;
+
+import javax.ejb.Stateless;
+
+/**
+ * @author Jerome Dochez
+ */
+@Stateless
+public class SampleEjb {
+
+    public String saySomething() {
+        return "Hello World";
+    }
+}
diff --git a/appserver/tests/embedded/static/ejb/simple/src/test/java/org/glassfish/tests/embedded/ejb/test/EmbeddedTest.java b/appserver/tests/embedded/static/ejb/simple/src/test/java/org/glassfish/tests/embedded/ejb/test/EmbeddedTest.java
new file mode 100644
index 0000000..f30aa33
--- /dev/null
+++ b/appserver/tests/embedded/static/ejb/simple/src/test/java/org/glassfish/tests/embedded/ejb/test/EmbeddedTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.ejb.test;
+
+import org.junit.Test;
+import org.junit.Assert;
+import org.glassfish.tests.embedded.ejb.SampleEjb;
+import org.glassfish.internal.embedded.*;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.*;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.File;
+
+/**
+ * this test will use the ejb API testing.
+ *
+ * @author Jerome Dochez
+ */
+public class EmbeddedTest {
+
+    @Test
+    public void test() throws Exception {
+        Server.Builder builder = new Server.Builder("simple");
+        Server server = builder.build();
+        File f = new File(System.getProperty("basedir"), "target");
+        f = new File(f, "classes");
+
+        ScatteredArchive archive = new ScatteredArchive.Builder("simple",f).buildJar();
+        server.addContainer(ContainerBuilder.Type.ejb);
+        try {
+            server.start();
+            String appName = null;
+            try {
+                appName = server.getDeployer().deploy(archive, null);
+            } catch (Exception e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+            assert(appName!=null);
+            try {
+                System.out.println("Looking up EJB...");
+                SampleEjb ejb = (SampleEjb) (new InitialContext()).lookup("java:global/simple/SampleEjb");
+                if (ejb!=null) {
+                    System.out.println("Invoking EJB...");
+                    System.out.println(ejb.saySomething());
+                    Assert.assertEquals(ejb.saySomething(), "Hello World");
+                }
+            } catch (Exception e) {
+                System.out.println("ERROR calling EJB:");
+                e.printStackTrace();
+                throw new RuntimeException(e);
+            }
+
+            server.getDeployer().undeploy(appName, null);
+        } finally {
+            server.stop();
+        }
+    }
+}
diff --git a/appserver/tests/embedded/static/pom.xml b/appserver/tests/embedded/static/pom.xml
new file mode 100755
index 0000000..8811363
--- /dev/null
+++ b/appserver/tests/embedded/static/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>static</artifactId>
+    <packaging>pom</packaging>
+    <name>GlassFish Static Embedded Tests</name>  
+    <modules>
+    	<module>ejb</module>
+        <module>web</module>      
+    </modules>
+</project>
diff --git a/appserver/tests/embedded/static/web/pom.xml b/appserver/tests/embedded/static/web/pom.xml
new file mode 100755
index 0000000..ad2417e
--- /dev/null
+++ b/appserver/tests/embedded/static/web/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.glassfish</groupId>
+        <artifactId>glassfish-parent</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>static</artifactId>
+    <name>Static embedded testing</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy</id>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>unpack</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.glassfish.distributions</groupId>
+                  <artifactId>web</artifactId>
+                  <version>${project.version}</version>
+                  <type>zip</type>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.4.2</version>
+        <configuration>
+          <forkMode>always</forkMode>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.main.extras</groupId>
+            <artifactId>glassfish-embedded-shell</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.glassfish.admin</groupId>
+        	<artifactId>config-api</artifactId>
+        	<version>${project.version}</version>
+        </dependency>            
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+   </dependencies>
+</project>
diff --git a/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/ExistingConfigurationTest.java b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/ExistingConfigurationTest.java
new file mode 100644
index 0000000..9a74ec5
--- /dev/null
+++ b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/ExistingConfigurationTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cooked;
+
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.embedded.Server;
+import org.glassfish.internal.embedded.EmbeddedFileSystem;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Collection;
+
+import com.sun.enterprise.config.serverbeans.VirtualServer;
+import org.glassfish.grizzly.config.dom.NetworkListener;
+
+/**
+ * @author Jerome Dochez
+ */
+public class ExistingConfigurationTest {
+
+    @Test
+    public void setupServer() throws Exception {
+
+        Server server=null;
+
+        System.out.println("setup started with gf installation " + System.getProperty("basedir"));
+        File f = new File(System.getProperty("basedir"));
+        f = new File(f, "target");
+        f = new File(f, "dependency");
+        f = new File(f, "glassfish5");
+        f = new File(f, "glassfish");
+        if (f.exists()) {
+            System.out.println("Using gf at " + f.getAbsolutePath());
+        } else {
+            System.out.println("GlassFish not found at " + f.getAbsolutePath());
+            Assert.assertTrue(f.exists());
+        }
+        try {
+            EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
+            efsb.installRoot(f, false);
+            // find the domain root.
+            f = new File(f,"domains");
+            f = new File(f, "domain1");
+            f = new File(f, "config");
+            f = new File(f, "domain.xml");
+            Assert.assertTrue(f.exists());
+            efsb.configurationFile(f);
+
+            Server.Builder builder = new Server.Builder("inplanted");
+            builder.embeddedFileSystem(efsb.build());
+            server = builder.build();
+
+            ServiceLocator habitat = server.getHabitat();
+            Collection<VirtualServer> vss = habitat.getAllServices(VirtualServer.class);
+            Assert.assertTrue(vss.size()>0);
+            for (VirtualServer vs : vss ) {
+                System.out.println("Virtual Server " + vs.getId());
+            }
+            Collection<NetworkListener> nls = habitat.getAllServices(NetworkListener.class);
+            for (NetworkListener nl : nls) {
+                System.out.println("Network listener " + nl.getPort());
+            }
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        } finally {
+            if (server!=null) {
+                server.stop();
+            }
+        }
+    }
+}
diff --git a/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/ExistingDomainTest.java b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/ExistingDomainTest.java
new file mode 100644
index 0000000..8372cfb
--- /dev/null
+++ b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/ExistingDomainTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cooked;
+
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.api.admin.*;
+import org.glassfish.api.container.Sniffer;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.AfterClass;
+
+import java.io.File;
+import java.util.Enumeration;
+
+/**
+ * Test embedded API with an existing domain.xml
+ *
+ * @author Jerome Dochez
+ */
+public class ExistingDomainTest {
+    static Server server;
+
+    @BeforeClass
+    public static void setupServer() throws Exception {
+        System.out.println("setup started with gf installation " + System.getProperty("basedir"));
+        File f = new File(System.getProperty("basedir"));
+        f = new File(f, "target");
+        f = new File(f, "dependency");
+        f = new File(f, "glassfish5");
+        f = new File(f, "glassfish");
+        if (f.exists()) {
+            System.out.println("Using gf at " + f.getAbsolutePath());
+        } else {
+            System.out.println("GlassFish not found at " + f.getAbsolutePath());
+            Assert.assertTrue(f.exists());
+        }
+        try {
+            EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
+            efsb.installRoot(f, false);
+            // find the domain root.
+            f = new File(f,"domains");
+            f = new File(f, "domain1");
+            Assert.assertTrue(f.exists());
+            efsb.instanceRoot(f);
+
+            Server.Builder builder = new Server.Builder("inplanted");
+            builder.embeddedFileSystem(efsb.build());
+            server = builder.build();
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+    //@Test
+    public void testWeb() throws Exception {
+        System.out.println("test web");
+        File f = new File(System.getProperty("basedir"));
+        f = new File(f, "target");
+        f = new File(f, "test-classes");
+        ScatteredArchive.Builder builder = new ScatteredArchive.Builder("hello", f);
+        builder.addClassPath(f.toURI().toURL());
+        builder.resources(f);
+        server.createPort(8080);
+        server.addContainer(server.createConfig(ContainerBuilder.Type.web));
+        DeployCommandParameters dp = new DeployCommandParameters(f);
+        ScatteredArchive war = builder.buildWar();
+        System.out.println("War content");
+        Enumeration<String> contents = war.entries();
+        while(contents.hasMoreElements()) {
+            System.out.println(contents.nextElement());
+        }
+        String appName = server.getDeployer().deploy(builder.buildWar(), dp);
+        server.getDeployer().undeploy(appName, null);
+    }
+
+    @Test
+    public void Test() {
+
+        ServiceLocator habitat = server.getHabitat();
+        System.out.println("Process type is " + habitat.<ProcessEnvironment>getService(ProcessEnvironment.class).getProcessType());
+        for (Sniffer s : habitat.<Sniffer>getAllServices(Sniffer.class)) {
+            System.out.println("Got sniffer " + s.getModuleType());
+        }
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws Exception {
+        System.out.println("shutdown initiated for server " + server);
+        if (server!=null) {
+            try {
+                server.stop();
+            } catch (LifecycleException e) {
+                e.printStackTrace();
+                throw e;
+            }
+        }
+
+
+    }
+    
+}
diff --git a/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/InplantedTest.java b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/InplantedTest.java
new file mode 100644
index 0000000..427081e
--- /dev/null
+++ b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/cooked/InplantedTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.cooked;
+
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.api.container.Sniffer;
+import org.glassfish.api.admin.*;
+import org.glassfish.api.deployment.DeployCommandParameters;
+
+import java.io.*;
+import java.util.Enumeration;
+
+/**
+ * @author Jerome Dochez
+ */
+public class InplantedTest {
+
+    static Server server;
+
+    @BeforeClass
+    public static void setupServer() throws Exception {
+        System.out.println("setup started with gf installation " + System.getProperty("basedir"));
+        File f = new File(System.getProperty("basedir"));
+        f = new File(f, "target");
+        f = new File(f, "dependency");
+        f = new File(f, "glassfish5");
+        f = new File(f, "glassfish");
+        if (f.exists()) {
+            System.out.println("Using gf at " + f.getAbsolutePath());
+        } else {
+            System.out.println("GlassFish not found at " + f.getAbsolutePath());
+            Assert.assertTrue(f.exists());
+        }
+        try {
+            EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
+            efsb.installRoot(f, false);
+            Server.Builder builder = new Server.Builder("inplanted");
+            builder.embeddedFileSystem(efsb.build());
+            server = builder.build();
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        System.out.println("test web");
+        File f = new File(System.getProperty("basedir"));
+        f = new File(f, "target");
+        f = new File(f, "test-classes");
+        ScatteredArchive.Builder builder = new ScatteredArchive.Builder("hello", f);
+        builder.addClassPath(f.toURI().toURL());
+        builder.resources(f);
+        ScatteredArchive war = builder.buildWar();
+        System.out.println("War content");
+        Enumeration<String> contents = war.entries();
+        while(contents.hasMoreElements()) {
+            System.out.println(contents.nextElement());
+        }
+        try {
+            System.out.println("Port created " + server.createPort(14587));
+            server.addContainer(ContainerBuilder.Type.web);
+            server.start();
+            DeployCommandParameters dp = new DeployCommandParameters(f);
+            String appName = server.getDeployer().deploy(war, dp);
+            System.out.println("Application deployed under name = " + appName);
+            if (appName!=null) {
+                server.getDeployer().undeploy(appName, null);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        } catch (LifecycleException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        } 
+    }
+
+    @Test
+    public void Test() {
+
+        ServiceLocator habitat = server.getHabitat();
+        System.out.println("Process type is " + habitat.<ProcessEnvironment>getService(ProcessEnvironment.class).getProcessType());
+        for (Sniffer s : habitat.<Sniffer>getAllServices(Sniffer.class)) {
+            System.out.println("Got sniffer " + s.getModuleType());
+        }
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws Exception {
+        System.out.println("shutdown initiated");
+        if (server!=null) {
+            try {
+                server.stop();
+            } catch (LifecycleException e) {
+                e.printStackTrace();
+                throw e;
+            }
+        }
+        
+        
+    }
+}
diff --git a/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/web/HelloWeb.java b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/web/HelloWeb.java
new file mode 100644
index 0000000..5b80833
--- /dev/null
+++ b/appserver/tests/embedded/static/web/src/test/java/org/glassfish/tests/embedded/web/HelloWeb.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+
+@WebServlet(urlPatterns={"/hello"})
+public class HelloWeb extends HttpServlet {
+
+    public HelloWeb() {
+        System.out.println("Servlet WEB-HELLO initialized");
+    }
+   
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+
+        PrintWriter pw = res.getWriter();
+        try {
+			pw.println("Hello World !");
+  		} catch(Exception e) {
+        	e.printStackTrace();
+        }
+    }
+}
diff --git a/appserver/tests/embedded/utils/pom.xml b/appserver/tests/embedded/utils/pom.xml
new file mode 100644
index 0000000..ccd70a8
--- /dev/null
+++ b/appserver/tests/embedded/utils/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>utils</artifactId>
+    <name>Utilities for embedded testing</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.main.extras</groupId>
+            <artifactId>glassfish-embedded-shell</artifactId>
+            <version>5.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+        </dependency>        
+    </dependencies>
+</project>
diff --git a/appserver/tests/embedded/utils/src/main/java/org/glassfish/tests/embedded/utils/EmbeddedServerUtils.java b/appserver/tests/embedded/utils/src/main/java/org/glassfish/tests/embedded/utils/EmbeddedServerUtils.java
new file mode 100644
index 0000000..4bf41fe
--- /dev/null
+++ b/appserver/tests/embedded/utils/src/main/java/org/glassfish/tests/embedded/utils/EmbeddedServerUtils.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.utils;
+
+import org.junit.Assert;
+import org.glassfish.internal.embedded.LifecycleException;
+import org.glassfish.internal.embedded.EmbeddedFileSystem;
+import org.glassfish.internal.embedded.Server;
+
+import java.io.File;
+
+public class EmbeddedServerUtils {
+
+    public static File getServerLocation() {
+        System.out.println("setup started with gf installation " + System.getProperty("basedir"));
+        File f = new File(System.getProperty("basedir"));
+        f = new File(f, "target");
+        f = new File(f, "dependency");
+        f = new File(f, "glassfish5");
+        f = new File(f, "glassfish");
+        if (f.exists()) {
+            System.out.println("Using gf at " + f.getAbsolutePath());
+        } else {
+            System.out.println("GlassFish not found at " + f.getAbsolutePath());
+            Assert.assertTrue(f.exists());
+        }
+        return f;
+    }
+    public static File getDomainLocation(File serverLocation) {
+        return getDomainLocation(serverLocation, "domain1");
+    }
+    
+    public static File getDomainLocation(File serverLocation, String domainName) {
+
+       // find the domain root.
+        File f = new File(serverLocation,"domains");
+        f = new File(f, domainName);
+        Assert.assertTrue(f.exists());
+        return f;
+    }
+
+    public static Server createServer(EmbeddedFileSystem fileSystem) throws Exception {
+        try {
+            Server.Builder builder = new Server.Builder("inplanted");
+            builder.embeddedFileSystem(fileSystem);
+            return builder.build();
+        } catch(Exception e) {
+            e.printStackTrace();
+            if (fileSystem.autoDelete) {
+                fileSystem.preDestroy();
+            }
+            throw e;
+        }
+    }
+
+    public static void shutdownServer(Server server) throws Exception {
+        System.out.println("shutdown initiated");
+        if (server!=null) {
+            try {
+                server.stop();
+            } catch (LifecycleException e) {
+                e.printStackTrace();
+                throw e;
+            }
+        }
+
+
+    }
+
+}
diff --git a/appserver/tests/embedded/web/autodelete/pom.xml b/appserver/tests/embedded/web/autodelete/pom.xml
new file mode 100644
index 0000000..924bb2e
--- /dev/null
+++ b/appserver/tests/embedded/web/autodelete/pom.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>web</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests.embedded.web</groupId>
+    <artifactId>autodelete</artifactId>
+    <packaging>war</packaging>
+    <name>Embedded file system deletion test</name>
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <inherited>true</inherited>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+            </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.1.1</version>
+          <executions>
+              <execution>
+                  <phase>test</phase>
+                  <goals>
+                      <goal>exec</goal>
+                  </goals>
+              </execution>
+          </executions>
+          <configuration>
+              <executable>java</executable>
+              <arguments>
+                  <!--argument>-Xdebug</argument>
+                  <argument>-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009</argument-->
+                  <argument>-classpath</argument>
+                  <classpath/>
+                  <argument>org.glassfish.tests.embedded.web.autodelete.ServletMain</argument>
+              </arguments>
+              <classpathScope>test</classpathScope>
+              <includeProjectDependencies>true</includeProjectDependencies>
+          </configuration>
+      </plugin>            
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.extras</groupId>
+            <artifactId>glassfish-embedded-web</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.htmlunit</groupId>
+            <artifactId>htmlunit</artifactId>
+            <version>2.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tests.embedded</groupId>
+            <artifactId>utils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/tests/embedded/web/autodelete/src/main/java/HelloWorld.java b/appserver/tests/embedded/web/autodelete/src/main/java/HelloWorld.java
new file mode 100644
index 0000000..557d417
--- /dev/null
+++ b/appserver/tests/embedded/web/autodelete/src/main/java/HelloWorld.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.annotation.WebServlet; 
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+@WebServlet(urlPatterns={"/hello"})
+public class HelloWorld extends HttpServlet {
+
+  
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+        
+        PrintWriter pw = res.getWriter();
+        try {
+			pw.println("Hello World !<br>");
+  		} catch(Exception e) {
+        	e.printStackTrace();
+        }
+    }
+}
+
diff --git a/appserver/tests/embedded/web/autodelete/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/web/autodelete/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..64a551b
--- /dev/null
+++ b/appserver/tests/embedded/web/autodelete/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app version="2.5"
+  xmlns="http://java.sun.com/xml/ns/javaee"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+</web-app>
+
diff --git a/appserver/tests/embedded/web/autodelete/src/test/java/org/glassfish/tests/embedded/web/autodelete/ServletMain.java b/appserver/tests/embedded/web/autodelete/src/test/java/org/glassfish/tests/embedded/web/autodelete/ServletMain.java
new file mode 100644
index 0000000..c7aedbc
--- /dev/null
+++ b/appserver/tests/embedded/web/autodelete/src/test/java/org/glassfish/tests/embedded/web/autodelete/ServletMain.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web.autodelete;
+
+import org.junit.*;
+import org.junit.Assert;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.api.deployment.*;
+
+import javax.naming.*;
+import java.io.*;
+import java.util.*;
+
+import com.gargoylesoftware.htmlunit.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dochez
+ * Date: Nov 4, 2009
+ * Time: 1:44:28 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ServletMain {
+
+    public static void main(String[] args) {
+        ServletMain test = new ServletMain();
+        System.setProperty("basedir", System.getProperty("user.dir"));
+        try {
+            test.test();
+        } catch (Exception e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
+        File instanceRoot = new File(System.getProperty("user.dir"), "embeddedMain");
+        System.out.println("Using instanceRoot " + instanceRoot.getAbsolutePath());
+        efsb.instanceRoot(instanceRoot).autoDelete(true);
+
+        Server server = new Server.Builder("web").embeddedFileSystem(efsb.build()).build();
+        try {
+            File f = new File(System.getProperty("basedir"));
+            f = new File(f, "target");
+            f = new File(f, "classes");
+            ScatteredArchive.Builder builder = new ScatteredArchive.Builder("hello", f);
+            builder.addClassPath(f.toURI().toURL());
+            builder.resources(f);
+            ScatteredArchive war = builder.buildWar();
+            System.out.println("War content");
+            Enumeration<String> contents = war.entries();
+            while(contents.hasMoreElements()) {
+                System.out.println(contents.nextElement());
+            }
+            Port port = server.createPort(8080);
+            server.addContainer(server.createConfig(ContainerBuilder.Type.web));
+            DeployCommandParameters dp = new DeployCommandParameters(f);
+            String appName = server.getDeployer().deploy(war, dp);
+            WebClient webClient = new WebClient();
+            try {
+                Page page =  webClient.getPage("http://localhost:8080/classes/hello");
+                System.out.println("Got response " + page.getWebResponse().getContentAsString());
+                Assert.assertTrue("Servlet returned wrong content", page.getWebResponse().getContentAsString().startsWith("Hello World"));
+            } finally {
+                System.out.println("Undeploying");
+                server.getDeployer().undeploy(appName, null);
+                port.close();
+            }
+            listDir(instanceRoot);
+
+        } finally {
+            System.out.println("Stopping the server !");
+            try {
+                server.stop();
+            } catch (LifecycleException e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+        }
+        if (instanceRoot.listFiles()!=null) {
+            listDir(instanceRoot);
+            throw new RuntimeException("some files were not cleaned");
+        }
+    }
+
+    private void listDir(File dir) {
+        if (!dir.exists()) {
+            System.out.println("Directory " + dir + " does not exist");
+            return;
+        }
+        for (File f : dir.listFiles()) {
+            if (f.isDirectory()) {
+                listDir(f);
+            } else {
+                System.out.println(f.getAbsolutePath());
+            }
+        }
+    }
+}
diff --git a/appserver/tests/embedded/web/pom.xml b/appserver/tests/embedded/web/pom.xml
new file mode 100755
index 0000000..e600c30
--- /dev/null
+++ b/appserver/tests/embedded/web/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>web</artifactId>
+    <packaging>pom</packaging>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>GlassFish Web Embedded Tests</name>  
+    <modules>
+        <module>web-api</module>
+    </modules>
+</project>
diff --git a/appserver/tests/embedded/web/servlet/pom.xml b/appserver/tests/embedded/web/servlet/pom.xml
new file mode 100644
index 0000000..d64b81f
--- /dev/null
+++ b/appserver/tests/embedded/web/servlet/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests.embedded</groupId>
+        <artifactId>web</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests.embedded.web</groupId>
+    <artifactId>servlet</artifactId>
+    <packaging>war</packaging>
+    <name>Simple embedded servlet project</name>
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <inherited>true</inherited>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+            </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.1.1</version>
+          <executions>
+              <execution>
+                  <phase>test</phase>
+                  <goals>
+                      <goal>exec</goal>
+                  </goals>
+              </execution>
+          </executions>
+          <configuration>
+              <executable>java</executable>
+              <arguments>
+                  <!--argument>-Xdebug</argument>
+                  <argument>-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009</argument-->
+                  <argument>-classpath</argument>
+                  <classpath/>
+                  <argument>org.glassfish.tests.embedded.web.servlet.ServletMain</argument>
+              </arguments>
+              <classpathScope>test</classpathScope>
+              <includeProjectDependencies>true</includeProjectDependencies>
+          </configuration>
+      </plugin>            
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.extras</groupId>
+            <artifactId>glassfish-embedded-web</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>${servlet-api.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.htmlunit</groupId>
+            <artifactId>htmlunit</artifactId>
+            <version>2.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tests.embedded</groupId>
+            <artifactId>utils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/tests/embedded/web/servlet/src/main/java/HelloWorld.java b/appserver/tests/embedded/web/servlet/src/main/java/HelloWorld.java
new file mode 100644
index 0000000..557d417
--- /dev/null
+++ b/appserver/tests/embedded/web/servlet/src/main/java/HelloWorld.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.annotation.WebServlet; 
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+@WebServlet(urlPatterns={"/hello"})
+public class HelloWorld extends HttpServlet {
+
+  
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+        
+        PrintWriter pw = res.getWriter();
+        try {
+			pw.println("Hello World !<br>");
+  		} catch(Exception e) {
+        	e.printStackTrace();
+        }
+    }
+}
+
diff --git a/appserver/tests/embedded/web/servlet/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/web/servlet/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..64a551b
--- /dev/null
+++ b/appserver/tests/embedded/web/servlet/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app version="2.5"
+  xmlns="http://java.sun.com/xml/ns/javaee"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+</web-app>
+
diff --git a/appserver/tests/embedded/web/servlet/src/test/java/org/glassfish/tests/embedded/web/servlet/ServletMain.java b/appserver/tests/embedded/web/servlet/src/test/java/org/glassfish/tests/embedded/web/servlet/ServletMain.java
new file mode 100644
index 0000000..63083a0
--- /dev/null
+++ b/appserver/tests/embedded/web/servlet/src/test/java/org/glassfish/tests/embedded/web/servlet/ServletMain.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web.servlet;
+
+import org.junit.*;
+import org.junit.Assert;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.api.deployment.*;
+
+import javax.naming.*;
+import java.io.*;
+import java.util.*;
+
+import com.gargoylesoftware.htmlunit.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dochez
+ * Date: Nov 4, 2009
+ * Time: 1:44:28 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ServletMain {
+
+    public static void main(String[] args) {
+        ServletMain test = new ServletMain();
+        System.setProperty("basedir", System.getProperty("user.dir"));
+        try {
+            test.test();
+        } catch (Exception e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        Server server = new Server.Builder("web").build();
+        try {
+            File f = new File(System.getProperty("basedir"));
+            f = new File(f, "target");
+            f = new File(f, "classes");
+            ScatteredArchive.Builder builder = new ScatteredArchive.Builder("hello", f);
+            builder.addClassPath(f.toURI().toURL());
+            builder.resources(f);
+            ScatteredArchive war = builder.buildWar();
+            System.out.println("War content");
+            Enumeration<String> contents = war.entries();
+            while(contents.hasMoreElements()) {
+                System.out.println(contents.nextElement());
+            }
+            Port port = server.createPort(8882);
+
+            server.addContainer(server.createConfig(ContainerBuilder.Type.web));
+            DeployCommandParameters dp = new DeployCommandParameters(f);
+            String appName = server.getDeployer().deploy(war, dp);
+            WebClient webClient = new WebClient();
+            try {
+                Page page =  webClient.getPage("http://localhost:8882/classes/hello");
+                System.out.println("Got response " + page.getWebResponse().getContentAsString());
+                Assert.assertTrue("Servlet returne wrong content", page.getWebResponse().getContentAsString().startsWith("Hello World"));
+                String hostName = System.getProperty("com.sun.aas.hostName");
+                assert hostName!=null;
+                page =  webClient.getPage("http://"+hostName+":8882/classes/hello");
+                System.out.println("Got response " + page.getWebResponse().getContentAsString());
+                Assert.assertTrue("Servlet returned wrong content", page.getWebResponse().getContentAsString().startsWith("Hello World"));
+            } finally {
+                System.out.println("Undeploying");
+                server.getDeployer().undeploy(appName, null);
+                port.close();
+            }
+
+        } finally {
+            System.out.println("Stopping the server !");
+            try {
+                server.stop();
+            } catch (LifecycleException e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+        }
+    }
+}
diff --git a/appserver/tests/embedded/web/web-all/pom.xml b/appserver/tests/embedded/web/web-all/pom.xml
new file mode 100644
index 0000000..7d42762
--- /dev/null
+++ b/appserver/tests/embedded/web/web-all/pom.xml
@@ -0,0 +1,167 @@
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <!--
+        It cant depend on parent pom. Certain extensions/plugin in the parent pom (probably
+        maven-buildglassfish-extension) brings in whole lot of v3 dependencies and during boot process
+        hk2 and other subsystems choke. So for now this test is not inheriting from the parent-pom till someone
+        investigates this issue further.                                                                                maven-buildglassfish-extension
+    -->
+    <!--<parent>-->
+    <!--<groupId>org.glassfish</groupId>-->
+    <!--<artifactId>glassfish-parent</artifactId>-->
+    <!--<version>5.0.1-SNAPSHOT</version>-->
+    <!--</parent>-->
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests</groupId>
+    <artifactId>web-all-embedded-test</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Test for glassfish-embedded-web</name>
+
+    <properties>
+        <project.version>4.1-SNAPSHOT</project.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.extras</groupId>
+            <artifactId>glassfish-embedded-web</artifactId>
+            <version>${project.version}</version>
+            <scope>system</scope>
+            <systemPath>${project.build.directory}/glassfish-embedded-web.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <systemProperties>
+                        <property>
+                            <name>buildDir</name>
+                            <value>${project.build.outputDirectory}</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.1</version>
+                <executions>
+                    <execution>
+                        <id>copy</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.glassfish.extras</groupId>
+                                    <artifactId>glassfish-embedded-web</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>jar</type>
+                                </artifactItem>
+                            </artifactItems>
+                            <outputDirectory>${project.build.directory}</outputDirectory>
+                            <stripVersion>true</stripVersion>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+	<profiles>
+        <profile>
+            <id>run-with-uber-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.extras</groupId>
+                    <artifactId>glassfish-embedded-all</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>                
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+	<dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+        </dependency>
+    </dependencies>    
+    <licenses>
+        <license>
+            <name>EPL 2.0</name>
+            <url>http://www.eclipse.org/legal/epl-2.0</url>
+            <distribution>repo</distribution>
+        </license>
+        <license>
+            <name>GPL2 w/ CPE</name>
+            <url>https://www.gnu.org/software/classpath/license.html</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+</project>
diff --git a/appserver/tests/embedded/web/web-all/src/main/java/org/glassfish/tests/weball/WebHello.java b/appserver/tests/embedded/web/web-all/src/main/java/org/glassfish/tests/weball/WebHello.java
new file mode 100644
index 0000000..1599e14
--- /dev/null
+++ b/appserver/tests/embedded/web/web-all/src/main/java/org/glassfish/tests/weball/WebHello.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.weball;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.annotation.Resource;
+
+/**
+ * @author Vivek Pandey
+ */
+@WebServlet(urlPatterns={"/hello"})
+public class WebHello extends HttpServlet {
+
+    public WebHello() {
+        System.out.println("Servlet WEB-HELLO initialized");
+    }
+
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+
+        PrintWriter pw = res.getWriter();
+        try {
+			pw.println("Hello World!");
+  		} catch(Exception e) {
+        	e.printStackTrace();
+        }
+    }
+}
diff --git a/appserver/tests/embedded/web/web-all/src/test/java/org/glassfish/tests/weball/WebAllTest.java b/appserver/tests/embedded/web/web-all/src/test/java/org/glassfish/tests/weball/WebAllTest.java
new file mode 100644
index 0000000..a56459e
--- /dev/null
+++ b/appserver/tests/embedded/web/web-all/src/test/java/org/glassfish/tests/weball/WebAllTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.weball;
+
+import org.glassfish.grizzly.config.dom.NetworkConfig;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.internal.embedded.*;
+import org.glassfish.api.embedded.web.*;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import org.glassfish.api.admin.ServerEnvironment;
+
+/**
+ * @author Vivek Pandey
+ */
+public class WebAllTest {
+    private static Server server = null;
+    private static Port http=null;
+    
+    @BeforeClass
+    public static void setup() throws IOException {
+
+        //create directory 'glassfish' inside target so that it gets cleaned by itself
+        EmbeddedFileSystem.Builder fsBuilder = new EmbeddedFileSystem.Builder();
+        String p = System.getProperty("buildDir");
+        File root = new File(p).getParentFile();
+        root =new File(root, "glassfish");
+        //If web container requires docroot to be there may be it should be automatically created by embedded API
+        new File(root, "docroot").mkdirs();
+
+        EmbeddedFileSystem fs = fsBuilder.instanceRoot(root).build();
+        Server.Builder builder = new Server.Builder("WebAllTest");
+        builder.embeddedFileSystem(fs);                
+        server = builder.build();
+        server.getHabitat().getService(NetworkConfig.class,
+                ServerEnvironment.DEFAULT_INSTANCE_NAME);
+        http = server.createPort(8080);
+        Assert.assertNotNull("Failed to create port 8080!", http);
+        ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
+        EmbeddedWebContainer embedded = (EmbeddedWebContainer) b.create(server);
+        embedded.setConfiguration((WebBuilder)b);
+        embedded.bind(http, "http");
+
+    }
+
+    @Test
+    public void testWeb() throws Exception {
+        System.out.println("Starting Web " + server);
+        ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
+
+        System.out.println("builder is " + b);
+        server.addContainer(b);
+        EmbeddedDeployer deployer = server.getDeployer();
+        System.out.println("Added Web");
+
+        String p = System.getProperty("buildDir");
+        System.out.println("Root is " + p);
+        ScatteredArchive.Builder builder = new ScatteredArchive.Builder("sampleweb", new File(p));
+        builder.resources(new File(p));
+        builder.addClassPath((new File(p)).toURL());
+        DeployCommandParameters dp = new DeployCommandParameters(new File(p));
+
+        System.out.println("Deploying " + p);
+        String appName = deployer.deploy(builder.buildWar(), dp);
+        Assert.assertNotNull("Deployment failed!", appName);
+
+        URL servlet = new URL("http://localhost:8080/classes/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+
+        Assert.assertEquals("Hello World!", sb.toString());
+
+        deployer.undeploy(appName, null);
+    }
+}
diff --git a/appserver/tests/embedded/web/web-api/pom.xml b/appserver/tests/embedded/web/web-api/pom.xml
new file mode 100755
index 0000000..24c786c
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/pom.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.tests.embedded</groupId>
+    <artifactId>web-api-embedded-test</artifactId>
+    <packaging>war</packaging>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Test for glassfish-embedded-web</name>
+
+    <build>
+        <testSourceDirectory>src/test/java</testSourceDirectory>
+        <testOutputDirectory>target/classes/WEB-INF/classes</testOutputDirectory>
+        <finalName>embedded-webapi-tests</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <forkMode>always</forkMode>
+                    <useSystemClassLoader>false</useSystemClassLoader>
+                    <useManifestOnlyJar>false</useManifestOnlyJar>
+                    <systemProperties>
+                        <property>
+                            <name>buildDir</name>
+                            <value>${project.build.outputDirectory}</value>
+                        </property>
+                        <property>
+                            <name>targetDir</name>
+                            <value>${project.build.directory}</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>run-with-web-jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-web</artifactId>
+                    <version>5.0.1-SNAPSHOT</version>
+                </dependency>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>run-with-shell-jar</id>
+            <activation>
+                <property>
+                    <name>build</name>
+                    <value>static-shell</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.12</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.glassfish.main.extras</groupId>
+                    <artifactId>glassfish-embedded-static-shell</artifactId>
+                    <version>${project.version}</version>
+                    <scope>system</scope>
+                    <systemPath>${env.S1AS_HOME}/lib/embedded/glassfish-embedded-static-shell.jar
+                    </systemPath>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/appserver/tests/embedded/web/web-api/src/main/java/TestCacaoList.java b/appserver/tests/embedded/web/web-api/src/main/java/TestCacaoList.java
new file mode 100644
index 0000000..4943d5e
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/java/TestCacaoList.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+public class TestCacaoList {}
diff --git a/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/CustomClassLoader.java b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/CustomClassLoader.java
new file mode 100644
index 0000000..fd5c7a6
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/CustomClassLoader.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.webapi;
+
+import java.io.*;
+import java.util.*;
+
+public class CustomClassLoader extends ClassLoader {
+
+    public CustomClassLoader(){
+        super(CustomClassLoader.class.getClassLoader());
+    }
+
+    public Class loadClass(String className) throws ClassNotFoundException {
+         return findClass(className);
+    }
+
+    public Class findClass(String className){
+        byte classByte[];
+        Class result=null;
+        result = (Class)classes.get(className);
+        if(result != null){
+            return result;
+        }
+
+        try{
+            return findSystemClass(className);
+        }catch(Exception e){
+        }
+
+        try{
+            String classPath =
+                   ((String)ClassLoader.getSystemResource(
+                           className.replace('.',File.separatorChar)+".class").getFile()).substring(1);
+            classByte = loadClassData(classPath);
+            result = defineClass(className,classByte,0,classByte.length,null);
+            classes.put(className,result);
+            return result;
+        }catch(Exception e){
+            return null;
+        }
+    }
+
+    private byte[] loadClassData(String className) throws IOException{
+
+        File f ;
+        f = new File(className);
+        int size = (int)f.length();
+        byte buff[] = new byte[size];
+        FileInputStream fis = new FileInputStream(f);
+        DataInputStream dis = new DataInputStream(fis);
+        dis.readFully(buff);
+        dis.close();
+        return buff;
+
+    }
+
+    private Hashtable classes = new Hashtable();
+
+}
diff --git a/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/HelloWeb.java b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/HelloWeb.java
new file mode 100644
index 0000000..bc41052
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/HelloWeb.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.webapi;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.annotation.Resource;
+
+@WebServlet(urlPatterns={"/hello"})
+public class HelloWeb extends HttpServlet {
+
+    public HelloWeb() {
+        System.out.println("Servlet WEB-HELLO initialized");
+    }
+   
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        PrintWriter pw = res.getWriter();
+        try {
+            pw.println("Hello World!");
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/TestListener.java b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/TestListener.java
new file mode 100644
index 0000000..6f390cf
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/TestListener.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.webapi;
+
+import java.io.PrintStream;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+public final class TestListener
+  implements ServletContextListener
+{
+  public static String msg = "Context not YET initialized";
+  
+  public void contextInitialized(ServletContextEvent event)
+  {
+    System.out.println("TestListener : contextInitialized called");
+    try
+    {
+      System.out.println("TestListener : Trying to load TestCacaoList");
+      
+      Class c = Class.forName("TestCacaoList");
+      
+      msg = "Class TestCacaoList loaded successfully from listener";
+      System.out.println(msg);
+    }
+    catch (Exception ex)
+    {
+      msg = "Exception while loading class TestCacaoList from listener : " + ex.toString();
+      System.out.println(msg);
+    }
+    System.out.println("TestListener : contextInitialized DONE");
+  }
+  
+  public void contextDestroyed(ServletContextEvent event) {}
+}
diff --git a/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/TestServlet.java b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/TestServlet.java
new file mode 100644
index 0000000..e8e11b4
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/java/org/glassfish/tests/webapi/TestServlet.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.webapi;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TestServlet
+  extends HttpServlet
+{
+  public String msg_listener = null;
+  
+  public void init(ServletConfig config)
+    throws ServletException
+  {
+    super.init(config);
+    
+    this.msg_listener = TestListener.msg;
+  }
+  
+  protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
+    throws ServletException, IOException
+  {
+    System.out.println("Servlet TestServlet doGet called");
+    
+    String msg_servlet = null;
+    try
+    {
+      Class c = Class.forName("TestCacaoList");
+      msg_servlet = "Class TestCacaoList loaded successfully from servlet";
+      System.out.println(msg_servlet);
+    }
+    catch (Exception ex)
+    {
+      msg_servlet = "Exception while loading class TestCacaoList from servlet : " + ex.toString();
+      System.out.println(msg_servlet);
+    }
+    PrintWriter out = httpServletResponse.getWriter();
+    out.println("CACAO Glash Fish Test Servlet with logs !!");
+    out.println("Context Init Msg = " + this.msg_listener);
+    out.println("Servlet Msg = " + msg_servlet);
+    out.flush();
+    out.close();
+    
+    System.out.println("Servlet TestServlet doGet DONE");
+  }
+}
diff --git a/appserver/tests/embedded/web/web-api/src/main/resources/cacerts.jks b/appserver/tests/embedded/web/web-api/src/main/resources/cacerts.jks
new file mode 100644
index 0000000..e271db8
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/resources/cacerts.jks
Binary files differ
diff --git a/appserver/tests/embedded/web/web-api/src/main/resources/embedded-webapi-tests.war b/appserver/tests/embedded/web/web-api/src/main/resources/embedded-webapi-tests.war
new file mode 100644
index 0000000..8666f3e
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/resources/embedded-webapi-tests.war
Binary files differ
diff --git a/appserver/tests/embedded/web/web-api/src/main/resources/keystore.jks b/appserver/tests/embedded/web/web-api/src/main/resources/keystore.jks
new file mode 100644
index 0000000..bd88aab
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/resources/keystore.jks
Binary files differ
diff --git a/appserver/tests/embedded/web/web-api/src/main/resources/org/glassfish/tests/webapi/domain.xml b/appserver/tests/embedded/web/web-api/src/main/resources/org/glassfish/tests/webapi/domain.xml
new file mode 100644
index 0000000..3d9e3f0
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/resources/org/glassfish/tests/webapi/domain.xml
@@ -0,0 +1,153 @@
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications" version="10.0">
+  <system-applications />
+  <applications />
+  <resources>
+    <jdbc-resource pool-name="__TimerPool" jndi-name="jdbc/__TimerPool" object-type="system-admin" />
+    <jdbc-resource pool-name="DerbyPool" jndi-name="jdbc/__default" />
+    <jdbc-connection-pool name="__TimerPool" datasource-classname="org.apache.derby.jdbc.EmbeddedXADataSource" res-type="javax.sql.XADataSource">
+      <property value="${com.sun.aas.instanceRoot}/lib/databases/ejbtimer" name="databaseName" />
+      <property value=";create=true" name="connectionAttributes" />
+    </jdbc-connection-pool>
+    <jdbc-connection-pool is-isolation-level-guaranteed="false" name="DerbyPool" datasource-classname="org.apache.derby.jdbc.ClientDataSource" res-type="javax.sql.DataSource">
+      <property value="1527" name="PortNumber" />
+      <property value="APP" name="Password" />
+      <property value="APP" name="User" />
+      <property value="localhost" name="serverName" />
+      <property value="sun-appserv-samples" name="DatabaseName" />
+      <property value=";create=true" name="connectionAttributes" />
+    </jdbc-connection-pool>
+  </resources>
+  <servers>
+    <server name="server" config-ref="server-config"> 
+      <resource-ref ref="jdbc/__TimerPool" />
+      <resource-ref ref="jdbc/__default" />
+    </server>
+  </servers>
+ <configs>
+   <config name="server-config">
+     <http-service access-logging-enabled="true">
+        <access-log rotation-interval-in-minutes="15" rotation-suffix="yyyy-MM-dd" />
+        <virtual-server id="server" access-logging-enabled="true"></virtual-server>
+      </http-service>
+      <iiop-service>
+        <orb use-thread-pool-ids="thread-pool-1" />
+        <iiop-listener address="0.0.0.0" port="3700" id="orb-listener-1" />
+        <iiop-listener security-enabled="true" address="0.0.0.0" port="3820" id="SSL">
+          <ssl cert-nickname="s1as" />
+        </iiop-listener>
+        <iiop-listener security-enabled="true" address="0.0.0.0" port="3920" id="SSL_MUTUALAUTH">
+          <ssl cert-nickname="s1as" client-auth-enabled="true" />
+        </iiop-listener>
+      </iiop-service>
+      <admin-service type="das-and-server" system-jmx-connector-name="system">
+        <jmx-connector enabled="false" auth-realm-name="admin-realm" security-enabled="false" address="0.0.0.0" port="8686" name="system" />
+        <das-config autodeploy-enabled="false" dynamic-reload-enabled="true" deploy-xml-validation="full" autodeploy-dir="${com.sun.aas.instanceRoot}/autodeploy" />
+        <property value="/admin" name="adminConsoleContextRoot" />
+        <property value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war" name="adminConsoleDownloadLocation" />
+        <property value="${com.sun.aas.installRoot}/.." name="ipsRoot" />
+      </admin-service>
+      <connector-service shutdown-timeout-in-seconds="30">
+      </connector-service>
+      <ejb-container steady-pool-size="0" max-pool-size="32" session-store="${com.sun.aas.instanceRoot}/session-store" pool-resize-quantity="8">
+        <ejb-timer-service />
+      </ejb-container>
+      <mdb-container steady-pool-size="0" max-pool-size="32" pool-resize-quantity="8" >
+      </mdb-container>
+      <jms-service type="EMBEDDED" default-jms-host="default_JMS_host">
+        <jms-host name="default_JMS_host" host="localhost" port="7676" admin-user-name="admin" admin-password="admin"/>
+      </jms-service>
+      <log-service file="${com.sun.aas.instanceRoot}/logs/server.log" log-rotation-limit-in-bytes="2000000">
+        <module-log-levels />
+      </log-service>
+      <security-service activate-default-principal-to-role-mapping="true" jacc="simple">
+        <auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="admin-realm">
+          <property value="admin-keyfile" name="file" />
+          <property value="fileRealm" name="jaas-context" />
+        </auth-realm>
+        <auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="file">
+          <property value="keyfile" name="file" />
+          <property value="fileRealm" name="jaas-context" />
+        </auth-realm>
+        <auth-realm classname="com.sun.enterprise.security.auth.realm.certificate.CertificateRealm" name="certificate" />
+        <jacc-provider policy-configuration-factory-provider="com.sun.enterprise.security.provider.PolicyConfigurationFactoryImpl" policy-provider="com.sun.enterprise.security.provider.PolicyWrapper" name="default">
+          <property value="${com.sun.aas.instanceRoot}/generated/policy" name="repository" />
+        </jacc-provider>
+        <jacc-provider policy-configuration-factory-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyConfigurationFactory" policy-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyProvider" name="simple" />
+        <audit-module classname="com.sun.enterprise.security.ee.Audit" name="default">
+          <property value="false" name="auditOn" />
+        </audit-module>
+        <message-security-config auth-layer="SOAP">
+          <provider-config provider-id="XWS_ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule" provider-type="client">
+            <request-policy auth-source="content" />
+            <response-policy auth-source="content" />
+            <property value="s1as" name="encryption.key.alias" />
+            <property value="s1as" name="signature.key.alias" />
+            <property value="false" name="dynamic.username.password" />
+            <property value="false" name="debug" />
+          </provider-config>
+          <provider-config provider-id="ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule" provider-type="client">
+            <request-policy auth-source="content" />
+            <response-policy auth-source="content" />
+            <property value="s1as" name="encryption.key.alias" />
+            <property value="s1as" name="signature.key.alias" />
+            <property value="false" name="dynamic.username.password" />
+            <property value="false" name="debug" />
+            <property value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml" name="security.config" />
+          </provider-config>
+          <provider-config provider-id="XWS_ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule" provider-type="server">
+            <request-policy auth-source="content" />
+            <response-policy auth-source="content" />
+            <property value="s1as" name="encryption.key.alias" />
+            <property value="s1as" name="signature.key.alias" />
+            <property value="false" name="debug" />
+          </provider-config>
+          <provider-config provider-id="ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule" provider-type="server">
+            <request-policy auth-source="content" />
+            <response-policy auth-source="content" />
+            <property value="s1as" name="encryption.key.alias" />
+            <property value="s1as" name="signature.key.alias" />
+            <property value="false" name="debug" />
+            <property value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml" name="security.config" />
+          </provider-config>
+        </message-security-config>
+      </security-service>
+      <monitoring-service>
+        <module-monitoring-levels />
+      </monitoring-service>      
+      <transaction-service tx-log-dir="${com.sun.aas.instanceRoot}/logs" >
+      </transaction-service>
+      <network-config>
+        <protocols>
+        </protocols>
+        <network-listeners>
+        </network-listeners>
+        <transports>
+          <transport name="tcp"></transport>
+        </transports>
+      </network-config>       
+      <thread-pools>
+          <thread-pool name="http-thread-pool" max-queue-size="4096"></thread-pool>
+          <thread-pool name="thread-pool-1" max-thread-pool-size="200"/>
+      </thread-pools>
+    </config> 
+  </configs>
+  <property name="administrative.domain.name" value="domain1"/>
+</domain>
diff --git a/appserver/tests/embedded/web/web-api/src/main/resources/org/glassfish/tests/webapi/my-default-web.xml b/appserver/tests/embedded/web/web-api/src/main/resources/org/glassfish/tests/webapi/my-default-web.xml
new file mode 100644
index 0000000..f1739e3
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/resources/org/glassfish/tests/webapi/my-default-web.xml
@@ -0,0 +1,1131 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+  <!-- ======================== Introduction ============================== -->
+
+
+  <!-- The default deployment descriptor.                                   -->
+  <!--                                                                      -->
+  <!-- The default deployment descriptor specifies default deployment       -->
+  <!-- descriptor values inherited by any web applications deployed to      -->
+  <!-- the application server.                                              -->
+
+
+  <!-- ============ Built In Context Init Parameter Definitions =========== -->
+
+
+  <!-- Init parameter to force the XML validation of JSF configuration  --> 
+  <!-- ressources.                                                      -->
+
+  <context-param>
+      <param-name>com.sun.faces.validateXml</param-name>
+      <param-value>true</param-value>
+  </context-param>
+
+  <!-- Init parameter will cause the JSF implementation to bypass      -->
+  <!-- processing the web.xml to determine if we should continue       --> 
+  <!-- bootstrapping JSF for the web application.                      -->
+
+  <context-param>
+      <param-name>com.sun.faces.forceLoadConfiguration</param-name>
+      <param-value>true</param-value>
+  </context-param> 
+      
+
+  <!-- ================== Built In Servlet Definitions ==================== -->
+
+
+  <!-- The DefaultDervlet, which is responsible for serving static          -->
+  <!-- resources.                                                           -->
+  <!-- This servlet processes any requests that are not mapped to other     -->
+  <!-- servlets with servlet mappings (defined either here or in your own   -->
+  <!-- web.xml file.  This servlet supports the following initialization    -->
+  <!-- parameters (default values have been placed in square brackets):     -->
+  <!--                                                                      -->
+  <!--   debug               Debugging detail level for messages logged     -->
+  <!--                       by this servlet.  [0]                          -->
+  <!--                                                                      -->
+  <!--   fileEncoding        Encoding to be used to read static resources   -->
+  <!--                       [platform default]                             -->
+  <!--                                                                      -->
+  <!--   input               Input buffer size (in bytes) when reading      -->
+  <!--                       resources to be served.  [2048]                -->
+  <!--                                                                      -->
+  <!--   listings            Should directory listings be produced if there -->
+  <!--                       is no welcome file in this directory?  [false] -->
+  <!--                       WARNING: Listings for directories with many    -->
+  <!--                       entries can be slow and may consume            -->
+  <!--                       significant proportions of server resources.   -->
+  <!--                                                                      -->
+  <!--   sortedBy            Specifies the criteria that will be used for   -->
+  <!--                       sorting directory entries. Legal values are    -->
+  <!--                       NAME, SIZE, and LAST_MODIFIED.  [NAME]         -->
+  <!--                                                                      -->
+  <!--   output              Output buffer size (in bytes) when writing     -->
+  <!--                       resources to be served.  [2048]                -->
+  <!--                                                                      -->
+  <!--   readonly            Is this context "read only", so HTTP           -->
+  <!--                       commands like PUT and DELETE are               -->
+  <!--                       rejected?  [true]                              -->
+  <!--                                                                      -->
+  <!--   readmeFile          File name to display with the directory        -->
+  <!--                       contents. [null]                               -->
+  <!--                                                                      -->
+  <!--   sendfileSize        If the connector used supports sendfile, this  -->
+  <!--                       represents the minimal file size in KB for     -->
+  <!--                       which sendfile will be used. Use a negative    -->
+  <!--                       value to always disable sendfile.  [48]        -->
+  <!--                                                                      -->
+  <!--   useAcceptRanges     Should the Accept-Ranges header be included    -->
+  <!--                       in responses where appropriate? [true]         -->
+  <!--                                                                      -->
+  <!--  For directory listing customization. Checks localXsltFile, then     -->
+  <!--  globalXsltFile, then defaults to original behavior.                 -->
+  <!--                                                                      -->
+  <!--   localXsltFile       Make directory listings an XML doc and         -->
+  <!--                       pass the result to this style sheet residing   -->
+  <!--                       in that directory. This overrides              -->
+  <!--                        globalXsltFile[null]                          -->
+  <!--                                                                      -->
+  <!--   globalXsltFile      Site wide configuration version of             -->
+  <!--                       localXsltFile This argument is expected        -->
+  <!--                       to be a physical file. [null]                  -->
+
+  <servlet>
+    <servlet-name>default</servlet-name>
+    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>0</param-value>
+    </init-param>
+    <init-param>
+      <param-name>listings</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+
+  <!-- The JSP page compiler and execution servlet, which is the mechanism  -->
+  <!-- used by the application server to support JSP pages.  Traditionally, -->
+  <!-- this servlet is mapped to the URL pattern "*.jsp".                   -->
+  <!-- This servlet supports the following initialization parameters        -->
+  <!-- (default values have been placed in square brackets):                -->
+  <!--                                                                      -->
+  <!--   checkInterval       If development is false and checkInterval is   -->
+  <!--                       greater than zero, background compilations are -->
+  <!--                       enabled. checkInterval is the time in seconds  -->
+  <!--                       between checks to see if a JSP page needs to   -->
+  <!--                       be recompiled. [0]                             -->
+  <!--                                                                      -->
+  <!--   modificationTestInterval                                           -->
+  <!--                       Causes a JSP (and its dependent files) to not  -->
+  <!--                       be checked for modification during the         -->
+  <!--                       specified time interval (in seconds) from the  -->
+  <!--                       last time the JSP was checked for              -->
+  <!--                       modification. A value of 0 will cause the JSP  -->
+  <!--                       to be checked on every access.                 -->
+  <!--                       Used in development mode only. [0]             -->
+  <!--                                                                      -->
+  <!--   compiler            Which compiler Ant should use to compile JSP   -->
+  <!--                       pages.  See the Ant documentation for more     -->
+  <!--                       information. [javac]                           -->
+  <!--                                                                      -->
+  <!--   classdebuginfo      Should the class file be compiled with         -->
+  <!--                       debugging information?  [true]                 -->
+  <!--                                                                      -->
+  <!--   classpath           What class path should I use while compiling   -->
+  <!--                       generated servlets?  [Created dynamically      -->
+  <!--                       based on the current web application]          -->
+  <!--                                                                      -->
+  <!--   development         Is Jasper used in development mode? If true,   -->
+  <!--                       the frequency at which JSPs are checked for    -->
+  <!--                       modification may be specified via the          -->
+  <!--                       modificationTestInterval parameter. [true]     -->
+  <!--                                                                      -->
+  <!--   enablePooling       Determines whether tag handler pooling is      -->
+  <!--                       enabled  [true]                                -->
+  <!--                                                                      -->
+  <!--   fork                Tell Ant to fork compiles of JSP pages so that -->
+  <!--                       JSP pages are compiled in their own JVM        -->
+  <!--                       (separate from the JVM that the application    -->
+  <!--                       server is running in). [true]                  -->
+  <!--                                                                      -->
+  <!--   ieClassId           The class-id value to be sent to Internet      -->
+  <!--                       Explorer when using <jsp:plugin> tags.         -->
+  <!--                       [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93]   -->
+  <!--                                                                      -->
+  <!--   javaEncoding        Java file encoding to use for generating java  -->
+  <!--                       source files. [UTF8]                           -->
+  <!--                                                                      -->
+  <!--   keepgenerated       Should we keep the generated Java source code  -->
+  <!--                       for each page instead of deleting it?          -->
+  <!--                       [true with JDK 5 and before, or for jspc]      -->
+  <!--                       [false otherwise]                              -->
+  <!--                                                                      -->
+  <!--   saveBytecode        Should the generated byte code be saved to     -->
+  <!--                       .class files?  This option is meaningful only  -->
+  <!--                       when Java compiler API, JSR199 (available with -->
+  <!--                       JDK 6) is used for javac compilations.         -->
+  <!--                       [false] [true for jspc]                        -->
+  <!--                                                                      -->
+  <!--   mappedfile          Should we generate static content with one     -->
+  <!--                       print statement per input line, to ease        -->
+  <!--                       debugging?  [true]                             -->
+  <!--                                                                      -->
+  <!--   trimSpaces          Should white spaces in template text between   -->
+  <!--                       actions or directives be trimmed?  [false]     -->
+  <!--                                                                      -->
+  <!--   suppressSmap        Should the generation of SMAP info for JSR45   -->
+  <!--                       debugging be suppressed?  [false]              -->
+  <!--                                                                      -->
+  <!--   dumpSmap            Should the SMAP info for JSR45 debugging be    -->
+  <!--                       dumped to a file? [false]                      -->
+  <!--                       False if suppressSmap is true                  -->
+  <!--                                                                      -->
+  <!--   genStrAsCharArray   Should text strings be generated as char       -->
+  <!--                       arrays, to improve performance in some cases?  -->
+  <!--                       [false]                                        -->
+  <!--                                                                      -->
+  <!--   genStrAsByteArray   Should text strings be generated as bytes      -->
+  <!--                       (encoded with the page encoding), if the page  -->
+  <!--                       is not buffered?                               -->
+  <!--                       [true]                                         -->
+  <!--                                                                      -->
+  <!--   defaultBufferNone   Should the default for the buffer attribute of -->
+  <!--                       the page directive be "none"?  [false]         -->
+  <!--                                                                      -->
+  <!--   errorOnUseBeanInvalidClassAttribute                                -->
+  <!--                       Should Jasper issue an error when the value of -->
+  <!--                       the class attribute in an useBean action is    -->
+  <!--                       not a valid bean class?  [false]               -->
+  <!--                                                                      -->
+  <!--   scratchdir          What scratch directory should we use when      -->
+  <!--                       compiling JSP pages?  [default work directory  -->
+  <!--                       for the current web application]               -->
+  <!--                                                                      -->
+  <!--   xpoweredBy          Determines whether X-Powered-By response       -->
+  <!--                       header is added by generated servlet  [true]   -->
+  <!--                                                                      -->
+  <!--   usePrecompiled      If true, it is assumed that JSPs have been     -->
+  <!--                       precompiled, and their corresponding servlet   -->
+  <!--                       classes have been bundled in the web           -->
+  <!--                       application's WEB-INF/lib or WEB-INF/classes,  -->
+  <!--                       so that when a JSP is accessed, it is not      -->
+  <!--                       compiled, and instead, its precompiled servlet -->
+  <!--                       class is used. [false]                         -->
+  <!--                                                                      -->
+  <!--   use-precompiled     Same as usePrecompiled. If both are specified, -->
+  <!--                       usePrecompiled takes precedence                -->
+  <!--                                                                      -->
+  <!--   initialCapacity     Initial capacity of HashMap mapping JSPs to    -->
+  <!--                       their corresponding servlets [32]              -->
+  <!--                                                                      -->
+  <!--   initial-capacity    Same as initialCapacity. If both are specified,-->
+  <!--                       initialCapacity takes precedence               -->
+  <!--                                                                      -->
+  <!--   httpMethods         Comma separated list of HTTP methods supported -->
+  <!--                       by the JspServlet. Wildcard ("*") denotes      -->
+  <!--                       "ALL METHODS". [ALL METHODS]                   -->
+  <!--                                                                      -->
+  <!--   reload-interval     Specifies the frequency (in seconds) at which  -->
+  <!--                       JSP files are checked for modifications.       -->
+  <!--                       Setting this value to 0 checks JSPs for        -->
+  <!--                       modifications on every request. Setting this   -->
+  <!--                       value to -1 disables checks for JSP            -->
+  <!--                       modifications and JSP recompilation.           -->
+  <!--                                                                      -->
+  <!--   compilerSourceVM    Provides source compatibility with the         -->
+  <!--                       specified JDK release (same as -source         -->
+  <!--                       javac command-line switch)                     -->
+  <!--                                                                      -->
+  <!--   compilerTargetVM    Generates class files for specified VM version -->
+  <!--                       (same as -target javac command-line switch)    -->
+  <!--                                                                      -->
+  <!-- If you wish to use Jikes to compile JSP pages:                       -->
+  <!-- * Set the "classpath" initialization parameter appropriately         -->
+  <!--   for this web application.                                          -->
+  <!-- * Set the "jspCompilerPlugin" initialization parameter to            -->
+  <!--   "org.apache.jasper.compiler.JikesJavaCompiler".                    -->
+
+  <servlet>
+    <servlet-name>jsp</servlet-name>
+    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+    <init-param>
+      <param-name>xpoweredBy</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <load-on-startup>3</load-on-startup>
+  </servlet>
+  
+
+  <!-- NOTE: An SSI Filter is also available as an alternative SSI          -->
+  <!-- implementation. Use either the Servlet or the Filter but NOT both.   -->
+  <!--                                                                      -->
+  <!-- Server Side Includes processing servlet, which processes SSI         -->
+  <!-- directives in HTML pages consistent with similar support in web      -->
+  <!-- servers like Apache.  Traditionally, this servlet is mapped to the   -->
+  <!-- URL pattern "*.shtml".  This servlet supports the following          -->
+  <!-- initialization parameters (default values are in square brackets):   -->
+  <!--                                                                      -->
+  <!--   buffered            Should output from this servlet be buffered?   -->
+  <!--                       (0=false, 1=true)  [0]                         -->
+  <!--                                                                      -->
+  <!--   debug               Debugging detail level for messages logged     -->
+  <!--                       by this servlet.  [0]                          -->
+  <!--                                                                      -->
+  <!--   expires             The number of seconds before a page with SSI   -->
+  <!--                       directives will expire.  [No default]          -->
+  <!--                                                                      -->
+  <!--   isVirtualWebappRelative                                            -->
+  <!--                       Should "virtual" paths be interpreted as       -->
+  <!--                       relative to the context root, instead of       -->
+  <!--                       the server root?  (0=false, 1=true) [0]        -->
+  <!--                                                                      -->
+  <!--   inputEncoding       The encoding to assume for SSI resources if    -->
+  <!--                       one is not available from the resource.        -->
+  <!--                       [Platform default]                             -->
+  <!--                                                                      -->
+  <!--   outputEncoding      The encoding to use for the page that results  -->
+  <!--                       from the SSI processing. [UTF-8]               -->
+
+<!--
+  <servlet>
+    <servlet-name>ssi</servlet-name>
+    <servlet-class>org.apache.catalina.ssi.SSIServlet</servlet-class>
+    <init-param>
+      <param-name>buffered</param-name>
+      <param-value>1</param-value>
+    </init-param>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>0</param-value>
+    </init-param>
+    <init-param>
+      <param-name>expires</param-name>
+      <param-value>666</param-value>
+    </init-param>
+    <init-param>
+      <param-name>isVirtualWebappRelative</param-name>
+      <param-value>0</param-value>
+    </init-param>
+    <load-on-startup>4</load-on-startup>
+  </servlet>
+-->
+
+
+  <!-- Common Gateway Includes (CGI) processing servlet, which supports     -->
+  <!-- execution of external applications that conform to the CGI spec      -->
+  <!-- requirements.  Typically, this servlet is mapped to the URL pattern  -->
+  <!-- "/cgi-bin/*", which means that any CGI applications that are         -->
+  <!-- executed must be present within the web application.  This servlet   -->
+  <!-- supports the following initialization parameters (default values     -->
+  <!-- are in square brackets):                                             -->
+  <!--                                                                      -->
+  <!--   cgiPathPrefix        The CGI search path will start at             -->
+  <!--                        webAppRootDir + File.separator + this prefix. -->
+  <!--                        [WEB-INF/cgi]                                 -->
+  <!--                                                                      -->
+  <!--   debug                Debugging detail level for messages logged    -->
+  <!--                        by this servlet.  [0]                         -->
+  <!--                                                                      -->
+  <!--   executable           Name of the executable used to run the        -->
+  <!--                        script. [perl]                                -->
+  <!--                                                                      -->
+  <!--   parameterEncoding    Name of parameter encoding to be used with    -->
+  <!--                        CGI servlet.                                  -->
+  <!--                        [System.getProperty("file.encoding","UTF-8")] -->
+  <!--                                                                      -->
+  <!--   passShellEnvironment Should the shell environment variables (if    -->
+  <!--                        any) be passed to the CGI script? [false]     -->
+  <!--                                                                      -->
+  <!--   stderrTimeout        The time (in milliseconds) to wait for the    -->
+  <!--                        reading of stderr to complete before          -->
+  <!--                        terminating the CGI process. [2000]           -->
+
+
+<!--
+  <servlet>
+    <servlet-name>cgi</servlet-name>
+    <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>0</param-value>
+    </init-param>
+    <init-param>
+      <param-name>cgiPathPrefix</param-name>
+      <param-value>WEB-INF/cgi</param-value>
+    </init-param>
+    <load-on-startup>5</load-on-startup>
+  </servlet>
+-->
+
+
+  <!-- ================ Built In Servlet Mappings ========================= -->
+
+  <!-- The mapping for the default servlet -->
+  <servlet-mapping>
+    <servlet-name>default</servlet-name>
+    <url-pattern>/</url-pattern>
+  </servlet-mapping>
+
+  <!-- The mapping for the JSP servlet -->
+  <servlet-mapping>
+    <servlet-name>jsp</servlet-name>
+    <url-pattern>*.jsp</url-pattern>
+    <url-pattern>*.jspx</url-pattern>
+  </servlet-mapping>
+
+  <!-- The mapping for the SSI servlet -->
+<!--
+  <servlet-mapping>
+    <servlet-name>ssi</servlet-name>
+    <url-pattern>*.shtml</url-pattern>
+  </servlet-mapping>
+-->
+
+  <!-- The mapping for the CGI Gateway servlet -->
+<!--
+  <servlet-mapping>
+    <servlet-name>cgi</servlet-name>
+    <url-pattern>/cgi-bin/*</url-pattern>
+  </servlet-mapping>
+-->
+
+
+  <!-- ================== Built In Filter Definitions ===================== -->
+
+  <!-- NOTE: An SSI Servlet is also available as an alternative SSI         -->
+  <!-- implementation. Use either the Servlet or the Filter but NOT both.   -->
+  <!--                                                                      -->
+  <!-- Server Side Includes processing filter, which processes SSI          -->
+  <!-- directives in HTML pages consistent with similar support in web      -->
+  <!-- servers like Apache.  Traditionally, this filter is mapped to the    -->
+  <!-- URL pattern "*.shtml", though it can be mapped to "*" as it will     -->
+  <!-- selectively enable/disable SSI processing based on mime types. For   -->
+  <!-- this to work you will need to uncomment the .shtml mime type         -->
+  <!-- definition towards the bottom of this file.                          -->
+  <!-- The contentType init param allows you to apply SSI processing to JSP -->
+  <!-- pages, javascript, or any other content you wish.  This filter       -->
+  <!-- supports the following initialization parameters (default values are -->
+  <!-- in square brackets):                                                 -->
+  <!--                                                                      -->
+  <!--   contentType         A regex pattern that must be matched before    -->
+  <!--                       SSI processing is applied.                     -->
+  <!--                       [text/x-server-parsed-html(;.*)?]              -->
+  <!--                                                                      -->
+  <!--   debug               Debugging detail level for messages logged     -->
+  <!--                       by this servlet.  [0]                          -->
+  <!--                                                                      -->
+  <!--   expires             The number of seconds before a page with SSI   -->
+  <!--                       directives will expire.  [No default]          -->
+  <!--                                                                      -->
+  <!--   isVirtualWebappRelative                                            -->
+  <!--                       Should "virtual" paths be interpreted as       -->
+  <!--                       relative to the context root, instead of       -->
+  <!--                       the server root?  (0=false, 1=true) [0]        -->
+
+<!--
+  <filter>
+    <filter-name>ssi</filter-name>
+    <filter-class>
+      org.apache.catalina.ssi.SSIFilter
+    </filter-class>
+    <init-param>
+      <param-name>contentType</param-name>
+      <param-value>text/x-server-parsed-html(;.*)?</param-value>
+    </init-param>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>0</param-value>
+    </init-param>
+    <init-param>
+      <param-name>expires</param-name>
+      <param-value>666</param-value>
+    </init-param>
+    <init-param>
+      <param-name>isVirtualWebappRelative</param-name>
+      <param-value>0</param-value>
+    </init-param>
+  </filter>
+-->
+
+
+  <!-- ==================== Built In Filter Mappings ====================== -->
+
+  <!-- The mapping for the SSI Filter -->
+<!--
+  <filter-mapping>
+    <filter-name>ssi</filter-name>
+    <url-pattern>*.shtml</url-pattern>
+  </filter-mapping>
+-->
+
+
+  <!-- ==================== Default Session Configuration ================= -->
+
+  <!-- You can set the default session timeout (in minutes) for all newly   -->
+  <!-- created sessions by modifying the value below.                       -->
+
+  <session-config>
+    <session-timeout>30</session-timeout>
+  </session-config>
+
+
+  <!-- ===================== Default MIME Type Mappings =================== -->
+
+  <!-- When serving static resources, the application server will           -->
+  <!-- automatically generate a "Content-Type" response header from the     -->
+  <!-- filename extension of the resource, based on these mappings.         -->
+  <!-- Additional mappings may be specified here (to be shared by all       -->
+  <!-- web applications) or in a web application's web.xml deployment       -->
+  <!-- descriptor (for that web application's individual use).              -->
+
+  <mime-mapping>
+    <extension>abs</extension>
+    <mime-type>audio/x-mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ai</extension>
+    <mime-type>application/postscript</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>aif</extension>
+    <mime-type>audio/x-aiff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>aifc</extension>
+    <mime-type>audio/x-aiff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>aiff</extension>
+    <mime-type>audio/x-aiff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>aim</extension>
+    <mime-type>application/x-aim</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>art</extension>
+    <mime-type>image/x-jg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>asf</extension>
+    <mime-type>video/x-ms-asf</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>asx</extension>
+    <mime-type>video/x-ms-asf</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>au</extension>
+    <mime-type>audio/basic</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>avi</extension>
+    <mime-type>video/x-msvideo</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>avx</extension>
+    <mime-type>video/x-rad-screenplay</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>bcpio</extension>
+    <mime-type>application/x-bcpio</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>bin</extension>
+    <mime-type>application/octet-stream</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>bmp</extension>
+    <mime-type>image/bmp</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>body</extension>
+    <mime-type>text/html</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>cdf</extension>
+    <mime-type>application/x-cdf</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>cer</extension>
+    <mime-type>application/x-x509-ca-cert</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>class</extension>
+    <mime-type>application/java</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>cpio</extension>
+    <mime-type>application/x-cpio</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>csh</extension>
+    <mime-type>application/x-csh</mime-type>
+  </mime-mapping>
+   <mime-mapping>
+    <extension>css</extension>
+    <mime-type>text/css</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>dib</extension>
+    <mime-type>image/bmp</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>doc</extension>
+    <mime-type>application/msword</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>dtd</extension>
+    <mime-type>application/xml-dtd</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>dv</extension>
+    <mime-type>video/x-dv</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>dvi</extension>
+    <mime-type>application/x-dvi</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>eps</extension>
+    <mime-type>application/postscript</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>etx</extension>
+    <mime-type>text/x-setext</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>exe</extension>
+    <mime-type>application/octet-stream</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>gif</extension>
+    <mime-type>image/gif</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>gk</extension>
+    <mime-type>application/octet-stream</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>gtar</extension>
+    <mime-type>application/x-gtar</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>gz</extension>
+    <mime-type>application/x-gzip</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>hdf</extension>
+    <mime-type>application/x-hdf</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>hqx</extension>
+    <mime-type>application/mac-binhex40</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>htc</extension>
+    <mime-type>text/x-component</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>htm</extension>
+    <mime-type>text/html</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>html</extension>
+    <mime-type>text/html</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>hqx</extension>
+    <mime-type>application/mac-binhex40</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ico</extension>
+    <mime-type>image/x-icon</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ief</extension>
+    <mime-type>image/ief</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>jad</extension>
+    <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>jar</extension>
+    <mime-type>application/java-archive</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>java</extension>
+    <mime-type>text/plain</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>jnlp</extension>
+    <mime-type>application/x-java-jnlp-file</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>jpe</extension>
+    <mime-type>image/jpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>jpeg</extension>
+    <mime-type>image/jpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>jpg</extension>
+    <mime-type>image/jpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>js</extension>
+    <mime-type>text/javascript</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>kar</extension>
+    <mime-type>audio/x-midi</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>latex</extension>
+    <mime-type>application/x-latex</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>m3u</extension>
+    <mime-type>audio/x-mpegurl</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mac</extension>
+    <mime-type>image/x-macpaint</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>man</extension>
+    <mime-type>application/x-troff-man</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mathml</extension>
+    <mime-type>application/mathml+xml</mime-type> 
+  </mime-mapping>
+  <mime-mapping>
+    <extension>me</extension>
+    <mime-type>application/x-troff-me</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mid</extension>
+    <mime-type>audio/x-midi</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>midi</extension>
+    <mime-type>audio/x-midi</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mif</extension>
+    <mime-type>application/x-mif</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mov</extension>
+    <mime-type>video/quicktime</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>movie</extension>
+    <mime-type>video/x-sgi-movie</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mp1</extension>
+    <mime-type>audio/x-mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mp2</extension>
+    <mime-type>audio/x-mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mp3</extension>
+    <mime-type>audio/x-mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mpa</extension>
+    <mime-type>audio/x-mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mpe</extension>
+    <mime-type>video/mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mpeg</extension>
+    <mime-type>video/mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mpega</extension>
+    <mime-type>audio/x-mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mpg</extension>
+    <mime-type>video/mpeg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>mpv2</extension>
+    <mime-type>video/mpeg2</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ms</extension>
+    <mime-type>application/x-wais-source</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>nc</extension>
+    <mime-type>application/x-netcdf</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>oda</extension>
+    <mime-type>application/oda</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ogg</extension>
+    <mime-type>application/ogg</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pbm</extension>
+    <mime-type>image/x-portable-bitmap</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pct</extension>
+    <mime-type>image/pict</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pdf</extension>
+    <mime-type>application/pdf</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pgm</extension>
+    <mime-type>image/x-portable-graymap</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pic</extension>
+    <mime-type>image/pict</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pict</extension>
+    <mime-type>image/pict</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pls</extension>
+    <mime-type>audio/x-scpls</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>png</extension>
+    <mime-type>image/png</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pnm</extension>
+    <mime-type>image/x-portable-anymap</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>pnt</extension>
+    <mime-type>image/x-macpaint</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ppm</extension>
+    <mime-type>image/x-portable-pixmap</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ppt</extension>
+    <mime-type>application/powerpoint</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ps</extension>
+    <mime-type>application/postscript</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>psd</extension>
+    <mime-type>image/x-photoshop</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>qt</extension>
+    <mime-type>video/quicktime</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>qti</extension>
+    <mime-type>image/x-quicktime</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>qtif</extension>
+    <mime-type>image/x-quicktime</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ras</extension>
+    <mime-type>image/x-cmu-raster</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>rdf</extension>
+    <mime-type>application/rdf+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>rgb</extension>
+    <mime-type>image/x-rgb</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>rm</extension>
+    <mime-type>application/vnd.rn-realmedia</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>roff</extension>
+    <mime-type>application/x-troff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>rtf</extension>
+    <mime-type>application/rtf</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>rtx</extension>
+    <mime-type>text/richtext</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>sh</extension>
+    <mime-type>application/x-sh</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>shar</extension>
+    <mime-type>application/x-shar</mime-type>
+  </mime-mapping>
+<!--
+  <mime-mapping>
+    <extension>shtml</extension>
+    <mime-type>text/x-server-parsed-html</mime-type>
+  </mime-mapping>
+-->
+  <mime-mapping>
+    <extension>sit</extension>
+    <mime-type>application/x-stuffit</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>smf</extension>
+    <mime-type>audio/x-midi</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>snd</extension>
+    <mime-type>audio/basic</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>src</extension>
+    <mime-type>application/x-wais-source</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>sv4cpio</extension>
+    <mime-type>application/x-sv4cpio</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>sv4crc</extension>
+    <mime-type>application/x-sv4crc</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>svg</extension>
+    <mime-type>image/svg+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>svgz</extension>
+    <mime-type>image/svg+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>swf</extension>
+    <mime-type>application/x-shockwave-flash</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>t</extension>
+    <mime-type>application/x-troff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>tar</extension>
+    <mime-type>application/x-tar</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>tcl</extension>
+    <mime-type>application/x-tcl</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>tex</extension>
+    <mime-type>application/x-tex</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>texi</extension>
+    <mime-type>application/x-texinfo</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>texinfo</extension>
+    <mime-type>application/x-texinfo</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>tif</extension>
+    <mime-type>image/tiff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>tiff</extension>
+    <mime-type>image/tiff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>tr</extension>
+    <mime-type>application/x-troff</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>tsv</extension>
+    <mime-type>text/tab-separated-values</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>txt</extension>
+    <mime-type>text/plain</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ulw</extension>
+    <mime-type>audio/basic</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ustar</extension>
+    <mime-type>application/x-ustar</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xbm</extension>
+    <mime-type>image/x-xbitmap</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xml</extension>
+    <mime-type>application/xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xpm</extension>
+    <mime-type>image/x-xpixmap</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xsl</extension>
+    <mime-type>application/xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xslt</extension>
+    <mime-type>application/xslt+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xwd</extension>
+    <mime-type>image/x-xwindowdump</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>vsd</extension>
+    <mime-type>application/x-visio</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>vxml</extension>
+    <mime-type>application/voicexml+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>wav</extension>
+    <mime-type>audio/x-wav</mime-type>
+  </mime-mapping>
+  <mime-mapping> <!-- Wireless Bitmap -->
+    <extension>wbmp</extension>
+    <mime-type>image/vnd.wap.wbmp</mime-type>
+  </mime-mapping>
+  <mime-mapping> <!-- WML Source -->
+    <extension>wml</extension>
+    <mime-type>text/vnd.wap.wml</mime-type>
+  </mime-mapping>
+  <mime-mapping> <!-- Compiled WML -->
+    <extension>wmlc</extension>
+    <mime-type>application/vnd.wap.wmlc</mime-type>
+  </mime-mapping>
+  <mime-mapping> <!-- WML Script Source -->
+    <extension>wmls</extension>
+    <mime-type>text/vnd.wap.wmls</mime-type>
+  </mime-mapping>
+  <mime-mapping> <!-- Compiled WML Script -->
+    <extension>wmlscriptc</extension>
+    <mime-type>application/vnd.wap.wmlscriptc</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>wrl</extension>
+    <mime-type>x-world/x-vrml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xht</extension>
+    <mime-type>application/xhtml+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xhtml</extension>
+    <mime-type>application/xhtml+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xls</extension>
+    <mime-type>application/vnd.ms-excel</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>xul</extension>
+    <mime-type>application/vnd.mozilla.xul+xml</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>Z</extension>
+    <mime-type>application/x-compress</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>z</extension>
+    <mime-type>application/x-compress</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>zip</extension>
+    <mime-type>application/zip</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>odp</extension>
+    <mime-type>application/x-vnd.oasis.opendocument.presentation</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>odt</extension>
+    <mime-type>application/x-vnd.oasis.opendocument.text</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>ods</extension>
+    <mime-type>application/x-vnd.oasis.opendocument.spreadsheet</mime-type>
+  </mime-mapping>
+  <mime-mapping>
+    <extension>odg</extension>
+    <mime-type>application/x-vnd.oasis.opendocument.graphics</mime-type>
+  </mime-mapping>
+
+
+  <!-- ==================== Default Welcome File List ===================== -->
+
+  <!-- When a request URI refers to a directory, the default servlet looks  -->
+  <!-- for a "welcome file" within that directory and, if present,          -->
+  <!-- to the corresponding resource URI for display.  If no welcome file   -->
+  <!-- is present, the default servlet either serves a directory listing,   -->
+  <!-- or returns a 404 status, depending on how it is configured.          -->
+  <!--                                                                      -->
+  <!-- If you define welcome files in your own application's web.xml        -->
+  <!-- deployment descriptor, that list *replaces* the list configured      -->
+  <!-- here, so be sure that you include any of the default values that     -->
+  <!-- you wish to include.                                                 -->
+
+
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.htm</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+  </welcome-file-list>
+
+  <login-config>
+    <auth-method>BASIC</auth-method>
+  </login-config>
+
+</web-app>
+
diff --git a/appserver/tests/embedded/web/web-api/src/main/resources/toto.jar b/appserver/tests/embedded/web/web-api/src/main/resources/toto.jar
new file mode 100644
index 0000000..67a09d1
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/resources/toto.jar
Binary files differ
diff --git a/appserver/tests/embedded/web/web-api/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/web/web-api/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..1b137e5
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
+<!--
+
+    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app> 
+
+    <display-name>toto</display-name>
+    <description>this a dummy web app</description>
+        
+    <listener>
+        <listener-class>org.glassfish.tests.webapi.TestListener</listener-class>
+    </listener>
+
+    <servlet>
+        <servlet-name>TestGF</servlet-name>
+        <description>Test GF root servlet</description>
+        <servlet-class>org.glassfish.tests.webapi.TestServlet</servlet-class>
+    </servlet>
+
+    <servlet>
+        <servlet-name>TestGF2</servlet-name>
+        <description>Test GF secondary servlet</description>
+        <servlet-class>org.glassfish.tests.webapi.TestServlet</servlet-class>
+    </servlet>
+    
+    <servlet-mapping>
+        <servlet-name>TestGF</servlet-name>
+        <url-pattern>/testgf</url-pattern>
+    </servlet-mapping>
+            
+    <servlet-mapping>
+        <servlet-name>TestGF2</servlet-name>
+        <url-pattern>/toto/testgf2</url-pattern>
+    </servlet-mapping>        
+    
+</web-app>
diff --git a/appserver/tests/embedded/web/web-api/src/main/webapp/index.jsp b/appserver/tests/embedded/web/web-api/src/main/webapp/index.jsp
new file mode 100644
index 0000000..b7199a2
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/webapp/index.jsp
@@ -0,0 +1,24 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+  <head><title>Simple jsp page</title></head>
+  <body>Place your content here</body>
+</html>
+
diff --git a/appserver/tests/embedded/web/web-api/src/main/webapp/response.jsp b/appserver/tests/embedded/web/web-api/src/main/webapp/response.jsp
new file mode 100644
index 0000000..09a6de7
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/main/webapp/response.jsp
@@ -0,0 +1,50 @@
+<%--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+--%>
+
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+
+<%@ page import="javax.servlet.http.*" %>
+
+<%
+    String user = (String)request.getParameter("username");
+    HttpSession httpSession = request.getSession();
+    String users = (String)httpSession.getAttribute("users");
+    if ( users == null ) {
+	users = user;
+    }
+    else {
+	users = users + ", " + user;
+    }
+    httpSession.setAttribute("users", users);
+%>
+
+
+<h2><font color="black"><fmt:message key="greeting_response" bundle="${resourceBundle}"/>, <%= users %>!</font></h2>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddContextTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddContextTest.java
new file mode 100644
index 0000000..5ac2138
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddContextTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#createContext
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddContextTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;                
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddContext Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setListings(true);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        Context context = embedded.createContext(root);
+        embedded.addContext(context, contextRoot);
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        Assert.assertEquals("server", vs.getID());
+        Assert.assertEquals("/"+contextRoot, vs.getContext(contextRoot).getPath());
+        boolean containsContext = false;
+        for (Context ctx : vs.getContexts()) {
+            System.out.println("Context found "+ctx.getPath());
+            if (ctx.getPath().endsWith(contextRoot)) {
+                containsContext = true;
+            }
+        }
+        Assert.assertTrue(containsContext);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        embedded.removeContext(context);
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddHttpsListenerTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddHttpsListenerTest.java
new file mode 100644
index 0000000..6d21938
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddHttpsListenerTest.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import java.net.*;
+import java.security.*;
+import java.security.cert.X509Certificate;
+import javax.net.ssl.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#addWebListener(HttpsListener)
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddHttpsListenerTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;                
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddHttpsListener Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setListings(true);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+
+    private void createHttpsListener(int port,
+                                     String name,
+                                     String keystore,
+                                     String password,
+                                     String certname) throws Exception {
+
+        HttpsListener listener = new HttpsListener();
+        listener.setPort(port);
+        listener.setId(name);
+
+        String keyStorePath = root.getAbsolutePath() + keystore;
+        String trustStorePath = root.getAbsolutePath() + "/cacerts.jks";
+        SslConfig sslConfig = new SslConfig(keyStorePath, trustStorePath);
+        sslConfig.setKeyPassword(password.toCharArray());
+        String trustPassword = "changeit";
+        sslConfig.setTrustPassword(trustPassword.toCharArray());
+        if (certname != null) {
+            sslConfig.setCertNickname(certname);
+        }
+        listener.setSslConfig(sslConfig);
+
+        embedded.addWebListener(listener);
+    }
+
+    private void verify(int port) throws Exception {
+
+        URL servlet = new URL("https://localhost:"+port+"/classes/hello");
+        HttpsURLConnection uc = (HttpsURLConnection) servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(sb);
+        Assert.assertEquals("Hello World!", sb.toString());
+    }
+
+    @Test
+    public void test() throws Exception {
+
+        createHttpsListener(9191, "default-ssl-listener", "/keystore.jks", "changeit", "s1as");
+        //createHttpsListener(9292, "ssl-listener0", "/keystore0", "password0", "keystore0");
+        //createHttpsListener(9393, "ssl-listener1", "/keystore1", "password1", null);
+
+        Deployer deployer = glassfish.getDeployer();
+
+        URL source = WebHello.class.getClassLoader().getResource(
+                "org/glassfish/tests/embedded/web/WebHello.class");
+        String p = source.getPath().substring(0, source.getPath().length() -
+                "org/glassfish/tests/embedded/web/WebHello.class".length());
+        File path = new File(p).getParentFile().getParentFile();
+
+        String name = null;
+        if (path.getName().lastIndexOf('.') != -1) {
+            name = path.getName().substring(0, path.getName().lastIndexOf('.'));
+        } else {
+            name = path.getName();
+        }
+
+        System.out.println("Deploying " + path + ", name = " + name);
+        String appName = deployer.deploy(path.toURI(), "--name=" + name);
+        System.out.println("Deployed " + appName);
+        Assert.assertTrue(appName != null);
+
+        disableCertValidation();
+        verify(9191);
+        //verify(9292);
+        //verify(9393);
+        
+        if (appName!=null)
+            deployer.undeploy(appName);
+        
+    }
+
+    public static void disableCertValidation() {
+        // Create a trust manager that does not validate certificate chains
+        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+            public X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+
+            public void checkClientTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+
+            public void checkServerTrusted(X509Certificate[] certs, String authType) {
+                return;
+            }
+        }};
+
+        try {
+            SSLContext sc = SSLContext.getInstance("TLS");
+            sc.init(null, trustAllCerts, new SecureRandom());
+            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+        } catch (Exception e) {
+            return;
+        }
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddListenerDefaultVSTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddListenerDefaultVSTest.java
new file mode 100644
index 0000000..d40ec3e
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddListenerDefaultVSTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for Context#addListener to default virtual server
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddListenerDefaultVSTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String vsname = "test-server";
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddListenerDefaultVS Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedAddServletDefaultVS() throws Exception {
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        System.out.println("Default virtual server "+vs);
+        Context context = (Context) embedded.createContext(root);
+        context.addListener("org.glassfish.tests.embedded.web.MyServletContextListener");
+        ServletRegistration sr = context.addServlet("MyServlet", "org.glassfish.tests.embedded.web.MyServlet");
+        sr.addMapping(new String[] {"/myservlet"});
+        vs.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/myservlet");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        vs.removeContext(context);
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletAndFilterByClassNameTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletAndFilterByClassNameTest.java
new file mode 100644
index 0000000..08cd16f
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletAndFilterByClassNameTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import javax.servlet.FilterRegistration;
+import javax.servlet.DispatcherType;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for Context addServlet & addFilter using class name to default virtual server
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddServletAndFilterByClassNameTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String vsname = "test-server";
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddServletAndFilterByClassNameTest Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedAddServletDefaultVS() throws Exception {
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        System.out.println("Default virtual server "+vs);
+        Context context = (Context) embedded.createContext(root);
+
+        ServletRegistration sr = context.addServlet("NewFilterServlet", "org.glassfish.tests.embedded.web.NewFilterServlet");
+        sr.setInitParameter("servletInitName", "servletInitValue");
+        sr.addMapping("/newFilterServlet");
+
+        FilterRegistration fr = context.addFilter("NewFilter", "org.glassfish.tests.embedded.web.NewFilter");
+        fr.setInitParameter("filterInitName", "filterInitValue");
+        fr.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST),
+                                     true, "NewFilterServlet");
+
+        vs.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/newFilterServlet");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        vs.removeContext(context);
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletAndFilterByClassTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletAndFilterByClassTest.java
new file mode 100644
index 0000000..c30e39e
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletAndFilterByClassTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
+import javax.servlet.DispatcherType;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for Context addServlet & addFilter using class to default virtual server
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddServletAndFilterByClassTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String vsname = "test-server";
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddServletAndFilterByClassNameTest Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedAddServletDefaultVS() throws Exception {
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        System.out.println("Default virtual server "+vs);
+        Context context = (Context) embedded.createContext(root);
+
+        ServletRegistration sr = context.addServlet("NewFilterServlet",
+            (Class <? extends Servlet>) getClass().getClassLoader().loadClass(
+                "org.glassfish.tests.embedded.web.NewFilterServlet"));
+        sr.setInitParameter("servletInitName", "servletInitValue");
+        sr.addMapping("/newFilterServlet");
+
+        FilterRegistration fr = context.addFilter("NewFilter",
+            (Class <? extends Filter>) getClass().getClassLoader().loadClass(
+                "org.glassfish.tests.embedded.web.NewFilter"));
+        fr.setInitParameter("filterInitName", "filterInitValue");
+        fr.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST),
+                                     true, "NewFilterServlet");
+
+        vs.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/newFilterServlet");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        vs.removeContext(context);
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletDefaultVSTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletDefaultVSTest.java
new file mode 100644
index 0000000..d3aa14e
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletDefaultVSTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for Context#addServlet to default virtual server
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddServletDefaultVSTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String vsname = "test-server";
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddServletDefaultVS Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedAddServletDefaultVS() throws Exception {
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        System.out.println("Default virtual server "+vs);
+        Context context = (Context) embedded.createContext(root);
+        ServletRegistration sr = context.addServlet("NewServlet", "org.glassfish.tests.embedded.web.NewServlet");
+        sr.addMapping(new String[] {"/newservlet"});
+        vs.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/newservlet");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        vs.removeContext(context);
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletTest.java
new file mode 100644
index 0000000..3cb2cf3
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddServletTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for Context#addServlet, embedded.createVirtualServer
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddServletTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String vsname = "test-server";
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddServlet Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedWebAPIConfig() throws Exception {
+        WebListener testListener = embedded.createWebListener("test-listener", HttpListener.class);
+        testListener.setPort(9090);
+        WebListener[] webListeners = new HttpListener[1];
+        webListeners[0] = testListener;
+
+        VirtualServerConfig config = new VirtualServerConfig();
+        config.setHostNames("localhost");
+        VirtualServer vs = (VirtualServer)
+                embedded.createVirtualServer(vsname, root, webListeners);
+        vs.setConfig(config);
+        embedded.addVirtualServer(vs);
+        boolean testvs = false;
+        for (VirtualServer avs : embedded.getVirtualServers()) {
+            System.out.println("virtual server "+avs.getID());
+            if (avs.getID().equals(vsname)) {
+                testvs=true;
+            }
+        }
+        Assert.assertTrue(testvs);    
+        Context context = (Context) embedded.createContext(root);
+        ServletRegistration sr = context.addServlet("NewServlet", "org.glassfish.tests.embedded.web.NewServlet");
+        sr.addMapping(new String[] {"/newservlet"});
+        vs.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:9090/"+contextRoot+"/newservlet");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        vs.removeContext(context);
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddWebListenerTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddWebListenerTest.java
new file mode 100644
index 0000000..b2cd3da
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedAddWebListenerTest.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URLConnection;
+import java.net.URL;
+import java.security.KeyStore;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#addWebListener(HttpListener) & HttpListener.setConfig
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedAddWebListenerTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;                
+    static String contextRoot = "test";
+    static int port = 9090;
+    static int newPort = 9292;
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddWebListener Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        HttpListener testListener = new HttpListener("test-listener", port);
+        embedded.addWebListener(testListener);
+
+        WebListenerConfig config = new WebListenerConfig("test-listener", newPort);
+        config.setProtocol("http");
+        testListener.setConfig(config);
+
+        List<WebListener> listenerList = new ArrayList(embedded.getWebListeners());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        Deployer deployer = glassfish.getDeployer();
+
+        URL source = WebHello.class.getClassLoader().getResource(
+                "org/glassfish/tests/embedded/web/WebHello.class");
+        String p = source.getPath().substring(0, source.getPath().length() -
+                "org/glassfish/tests/embedded/web/WebHello.class".length());
+        File path = new File(p).getParentFile().getParentFile();
+
+        String name = null;
+
+        if (path.getName().lastIndexOf('.') != -1) {
+            name = path.getName().substring(0, path.getName().lastIndexOf('.'));
+        } else {
+            name = path.getName();
+        }
+
+        System.out.println("Deploying " + path + ", name = " + name);
+
+        String appName = deployer.deploy(path.toURI(), "--contextroot", contextRoot, "--name=" + name);
+
+        System.out.println("Deployed " + appName);
+
+        Assert.assertTrue(appName != null);
+
+        URL servlet = new URL("http://localhost:"+newPort+"/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+        
+        if (appName!=null)
+            deployer.undeploy(appName);
+        
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedClassLoaderTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedClassLoaderTest.java
new file mode 100644
index 0000000..79a9539
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedClassLoaderTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.util.logging.Level;
+
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class EmbeddedClassLoaderTest {
+
+    static GlassFish glassfish;
+    static String contextRoot = "test";
+    static WebContainer wc;
+    static File root;
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        root = new File("target/classes");
+
+        wc = glassfish.getService(WebContainer.class);
+        wc.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setListings(true);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        wc.setConfiguration(config);
+    }
+
+    private static void loadA(ClassLoader cl) {
+        String className = "TestCacaoList";
+        try {
+            System.out.println("---> Loading " + className + " with " + cl);
+            cl.loadClass(className);
+            System.out.println("---> Finish to load " + className + " with " + cl);
+        } catch(Exception ex) {
+            System.out.println("---> Cannot load " + className + " with " + cl + ": " + ex);
+            throw new IllegalStateException();
+        }
+    }
+    
+    @Test
+    public void test() throws Exception {
+        URL[] urls = new URL[1];
+        urls[0] = (new File("src/main/resources/toto.jar")).toURI().toURL();
+        URLClassLoader classLoader = new URLClassLoader(urls, EmbeddedClassLoaderTest.class.getClassLoader());
+        loadA(classLoader);
+
+        Thread.currentThread().setContextClassLoader(classLoader);
+
+        File path = new File("src/main/resources/embedded-webapi-tests.war");
+
+        Context context = wc.createContext(path, classLoader);
+        wc.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:8080/test/testgf");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+
+        boolean success = sb.toString().contains("Class TestCacaoList loaded successfully from listener");
+        if (success) {
+            success = sb.toString().contains("Class TestCacaoList loaded successfully from servlet");
+        }
+        Assert.assertTrue(success);
+        in.close();
+
+        wc.removeContext(context);
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateContextTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateContextTest.java
new file mode 100644
index 0000000..1597893
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateContextTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#createContext
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedCreateContextTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedCreateContext Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+    }
+    
+    @Test
+    public void test() throws Exception {
+        
+        HttpListener listener = new HttpListener();
+        listener.setPort(8080);
+        listener.setId("embedded-listener-1");
+        embedded.addWebListener(listener);
+
+        File docRoot = new File("target/classes");
+        Context context = (Context) embedded.createContext(docRoot, contextRoot, null);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateServletAndFilterTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateServletAndFilterTest.java
new file mode 100644
index 0000000..eae42e1
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateServletAndFilterTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
+import javax.servlet.DispatcherType;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for Context createServlet & createFilter using class to default virtual server
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedCreateServletAndFilterTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String vsname = "test-server";
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedAddServletAndFilterByClassNameTest Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedAddServletDefaultVS() throws Exception {
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        System.out.println("Default virtual server "+vs);
+        Context context = (Context) embedded.createContext(root);
+
+        Class<NewFilterServlet> servletCl = (Class<NewFilterServlet>)
+            Class.forName("org.glassfish.tests.embedded.web.NewFilterServlet");
+        NewFilterServlet filterServlet = context.createServlet(servletCl);
+        ServletRegistration sr = context.addServlet("NewFilterServlet", filterServlet);
+        sr.setInitParameter("servletInitName", "servletInitValue");
+        sr.addMapping("/newFilterServlet");
+
+        Class<NewFilter> filterCl = (Class<NewFilter>)
+            Class.forName("org.glassfish.tests.embedded.web.NewFilter");
+        NewFilter filter = context.createFilter(filterCl);
+        FilterRegistration fr = context.addFilter("NewFilter", filter);
+        fr.setInitParameter("filterInitName", "filterInitValue");
+        fr.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST),
+                                     true, "NewFilterServlet");
+
+        vs.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/newFilterServlet");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        vs.removeContext(context);
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateVirtualServerTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateVirtualServerTest.java
new file mode 100644
index 0000000..8a2b5c3
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedCreateVirtualServerTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;  
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#createVirtualServerTest
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedCreateVirtualServerTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static int newPort = 9090;
+    static String contextRoot = "test";
+    
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedCreateVirtualServer Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        HttpListener httpListener = new HttpListener();
+        httpListener.setPort(8080);
+        httpListener.setId("embedded-listener-1");
+        embedded.addWebListener(httpListener);
+        
+        List<WebListener> listenerList = new ArrayList(embedded.getWebListeners());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        WebListener testListener = embedded.createWebListener("test-listener", HttpListener.class);
+        testListener.setPort(newPort);
+        WebListener[] webListeners = new HttpListener[1];
+        webListeners[0] = testListener;
+        
+        File f = new File("target/classes");
+        String virtualServerId = "embedded-server";
+        VirtualServer virtualServer = (VirtualServer)
+                embedded.createVirtualServer(virtualServerId, f, webListeners);         
+        VirtualServerConfig config = new VirtualServerConfig();
+        config.setHostNames("localhost");
+        virtualServer.setConfig(config);
+        embedded.addVirtualServer(virtualServer);
+
+        listenerList = new ArrayList(embedded.getWebListeners());
+        System.out.println("Network listener size after creation " + listenerList.size());
+        Assert.assertTrue(listenerList.size()==2);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        VirtualServer vs = embedded.getVirtualServer(virtualServerId);
+        Assert.assertEquals(virtualServerId,vs.getID());
+
+        File docRoot = new File("target/classes");
+        Context context = (Context) embedded.createContext(docRoot);
+        vs.addContext(context, contextRoot);
+
+        URL servlet = new URL("http://localhost:"+newPort+"/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+
+        vs.removeContext(context);
+        System.out.println("Removing web listener "+testListener.getId());
+        embedded.removeWebListener(testListener);                       
+
+        listenerList = new ArrayList(embedded.getWebListeners());
+        System.out.println("Network listener size after deletion " + listenerList.size());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedGetContextsTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedGetContextsTest.java
new file mode 100644
index 0000000..4730ff6
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedGetContextsTest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests VirtualServer#getContexts after deploy
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedGetContextsTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;                
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedGetContexts Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        HttpListener httpListener = new HttpListener();
+        httpListener.setPort(8080);
+        httpListener.setId("embedded-listener-1");
+        embedded.addWebListener(httpListener);
+
+        List<WebListener> listenerList = new ArrayList(embedded.getWebListeners());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        Deployer deployer = glassfish.getDeployer();
+
+        URL source = WebHello.class.getClassLoader().getResource(
+                "org/glassfish/tests/embedded/web/WebHello.class");
+        String p = source.getPath().substring(0, source.getPath().length() -
+                "org/glassfish/tests/embedded/web/WebHello.class".length());
+        File path = new File(p).getParentFile().getParentFile();
+
+        String name = null;
+
+        if (path.getName().lastIndexOf('.') != -1) {
+            name = path.getName().substring(0, path.getName().lastIndexOf('.'));
+        } else {
+            name = path.getName();
+        }
+
+        System.out.println("Deploying " + path + ", name = " + name);
+
+        String appName = deployer.deploy(path.toURI(), "--contextroot", contextRoot, "--name=" + name);
+
+        System.out.println("Deployed " + appName);
+
+        Assert.assertTrue(appName != null);
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        Assert.assertEquals("server", vs.getID());
+        Assert.assertEquals("/"+contextRoot, vs.getContext(contextRoot).getPath());
+        boolean containsContext = false;
+        for (Context ctx : vs.getContexts()) {
+            System.out.println("Context found "+ctx.getPath());
+            if (ctx.getPath().endsWith(contextRoot)) {
+                containsContext = true;
+            }
+        }
+        Assert.assertTrue(containsContext);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+
+        if (appName!=null)
+            deployer.undeploy(appName);
+
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedJSPTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedJSPTest.java
new file mode 100644
index 0000000..9725c86
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedJSPTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URL;
+import java.net.URLConnection;
+import org.apache.catalina.logger.SystemOutLogger;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.embeddable.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Amy Roh
+ */
+public class EmbeddedJSPTest {
+
+    static GlassFish glassfish;
+    static File path;
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        GlassFishProperties gp = new GlassFishProperties();
+        gp.setPort("http-listener", 8080);
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish(gp);
+        glassfish.start();
+        System.out.println("================ Embedded JSP Test");
+    }
+    
+    @Test
+    public void testDefaultStart() throws Exception {
+
+        Deployer deployer = glassfish.getDeployer();
+
+        path = new File("src/main/resources/embedded-webapi-tests.war");
+
+        String name = null;
+
+        if (path.getName().lastIndexOf('.') != -1) {
+            name = path.getName().substring(0, path.getName().lastIndexOf('.'));
+        } else {
+            name = path.getName();
+        }
+
+        System.out.println("Deploying " + path + ", name = " + name);
+
+        String appName = deployer.deploy(path.toURI(), "--name=" + name);
+
+        System.out.println("Deployed " + appName);
+
+        Assert.assertTrue(appName != null);
+
+        /*
+        URL servlet = new URL("http://localhost:8080/hellojsp/index.jsp");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        */
+        
+        if (appName!=null)
+            deployer.undeploy(appName);
+
+        System.out.println("Undeployed "+appName);
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRedeployTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRedeployTest.java
new file mode 100644
index 0000000..7c01ddd
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRedeployTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests redeploy scenario
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedRedeployTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;                
+    static String contextRoot = "/embedded-redeploy";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedRemoveContext Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setListings(true);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        Context context = embedded.createContext(root);
+        embedded.addContext(context, contextRoot);
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        String path = vs.getContext(contextRoot).getPath();
+        Assert.assertEquals(path, contextRoot);
+        invoke();
+
+        embedded.removeContext(context);
+        Assert.assertNull(vs.getContext(contextRoot));
+
+        embedded.addContext(context, contextRoot);
+        Assert.assertEquals(path, contextRoot);
+
+        invoke();
+
+        embedded.removeContext(context);
+        Assert.assertNull(vs.getContext(contextRoot));
+
+    }
+
+    private void invoke() throws Exception {
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        System.out.println(sb);
+        in.close();
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRemoveContextTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRemoveContextTest.java
new file mode 100644
index 0000000..03a812f
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRemoveContextTest.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#removeContext
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedRemoveContextTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;                
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedRemoveContext Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setListings(true);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        Context context = embedded.createContext(root);
+        embedded.addContext(context, contextRoot);
+
+        VirtualServer vs = embedded.getVirtualServer("server");
+        Assert.assertEquals("server", vs.getID());
+        Assert.assertEquals("/"+contextRoot, vs.getContext(contextRoot).getPath());
+        boolean containsContext = false;
+        for (Context ctx : vs.getContexts()) {
+            System.out.println("Context found "+ctx.getPath());
+            if (ctx.getPath().endsWith(contextRoot)) {
+                containsContext = true;
+            }
+        }
+        Assert.assertTrue(containsContext);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        embedded.removeContext(context);
+
+        Assert.assertNull(vs.getContext(contextRoot));
+
+        containsContext = false;
+        for (Context ctx : vs.getContexts()) {
+            System.out.println("Context found "+ctx.getPath());
+            if (ctx.getPath().endsWith(contextRoot)) {
+                containsContext = true;
+            }
+        }
+        Assert.assertTrue(!containsContext);
+
+        embedded.addContext(context, contextRoot);
+
+        Assert.assertEquals("/"+contextRoot, vs.getContext(contextRoot).getPath());
+        for (Context ctx : vs.getContexts()) {
+            System.out.println("Context found "+ctx.getPath());
+            if (ctx.getPath().endsWith(contextRoot)) {
+                containsContext = true;
+            }
+        }
+        Assert.assertTrue(containsContext);
+        yc = servlet.openConnection();
+        in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+
+        sb = new StringBuilder();
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+
+        embedded.removeContext(context);
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRestartTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRestartTest.java
new file mode 100644
index 0000000..8a2c541
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedRestartTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import org.glassfish.embeddable.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests GlassFish restart
+ *
+ * @author Amy Roh
+ */
+public class EmbeddedRestartTest {
+
+    static GlassFish glassfish;
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        GlassFishProperties gp = new GlassFishProperties();
+        gp.setPort("http-listener", 8080);
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish(gp);
+        glassfish.start();
+        System.out.println("================ Embedded Restart Test");
+    }
+    
+    @Test
+    public void testEmbeddedWebAPI() throws Exception {
+
+        // Restart is not working. Uncomment this to see the issue.
+        //glassfish.stop();
+        //glassfish.start();
+
+        Deployer deployer = glassfish.getDeployer();
+
+        URL source = WebHello.class.getClassLoader().getResource(
+                "org/glassfish/tests/embedded/web/WebHello.class");
+        String p = source.getPath().substring(0, source.getPath().length() -
+                "org/glassfish/tests/embedded/web/WebHello.class".length());
+        File path = new File(p).getParentFile().getParentFile();
+
+        String name = null;
+
+        if (path.getName().lastIndexOf('.') != -1) {
+            name = path.getName().substring(0, path.getName().lastIndexOf('.'));
+        } else {
+            name = path.getName();
+        }
+
+        System.out.println("Deploying " + path + ", contextroot = " + contextRoot);
+
+        String appName = deployer.deploy(path.toURI(), "--contextroot", contextRoot);
+
+        System.out.println("Deployed " + appName);
+
+        Assert.assertTrue(appName != null);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+
+        System.out.println("Undeploying "+appName);
+        if (appName!=null)
+            deployer.undeploy(appName);
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetConfigurationTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetConfigurationTest.java
new file mode 100644
index 0000000..19509e3
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetConfigurationTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#setConfiguration(WebContainerConfig)
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedSetConfigurationTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedSetConfiguration Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        config.setHostNames("localhost");
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedWebAPIConfig() throws Exception {
+        Context context = embedded.createContext(root);
+        embedded.addContext(context, "/");
+
+        URL servlet = new URL("http://localhost:8080");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetDefaultWebXmlTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetDefaultWebXmlTest.java
new file mode 100644
index 0000000..befbf57
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetDefaultWebXmlTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests EmbeddedFileSystem.configurationFile and WebBuilder.setDefaultWebXml
+ * Checks if directory listings is correctly getting picked up from the default-web.xml
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedSetDefaultWebXmlTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws Exception {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedSetDefaultWebXml Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        root = new File("target/classes");
+        File defaultWebXml = new File(root+"/org/glassfish/tests/webapi/my-default-web.xml");
+        config.setDefaultWebXml(defaultWebXml.toURL());
+        System.out.println("Using default-web.xml "+defaultWebXml.getAbsolutePath());
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedWebAPIConfig() throws Exception {
+
+        Context context = embedded.createContext(root);
+        embedded.addContext(context, contextRoot);
+
+        // test if dir listing is getting picked up from default-web.xml
+        URL servlet = new URL("http://localhost:8080/"+contextRoot);
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        
+        embedded.removeContext(context);
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetDocRootTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetDocRootTest.java
new file mode 100644
index 0000000..c8784d5
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetDocRootTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRegistration;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebBuilding#setListings for directory listing feature
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedSetDocRootTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedSetDocRoot Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        config.setListings(true);
+        root = new File("target/classes");
+        config.setDocRootDir(root);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void testEmbeddedWebAPIConfig() throws Exception {
+        VirtualServer vs = (VirtualServer)
+                embedded.createVirtualServer("test-server", root);
+        VirtualServerConfig config = new VirtualServerConfig();
+        config.setHostNames("localhost");
+        vs.setConfig(config);
+        embedded.addVirtualServer(vs);
+        Context context = (Context) embedded.createContext(root, contextRoot, null);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot);
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetSecurityTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetSecurityTest.java
new file mode 100644
index 0000000..179fbab
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedSetSecurityTest.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests Context#setSecurity
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedSetSecurityTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static File root;                
+    static String contextRoot = "security";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedSetSecurity Test");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+        WebContainerConfig config = new WebContainerConfig();
+        root = new File("target/classes");
+        //root = new File("/tests/security");
+        config.setDocRootDir(root);
+        config.setListings(true);
+        config.setPort(8080);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        embedded.setConfiguration(config);
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        try {
+
+        Context context = embedded.createContext(root);
+        embedded.addContext(context, contextRoot);
+
+        FormLoginConfig form = new FormLoginConfig("/login.html", "/error.html");
+
+        LoginConfig loginConfig = new LoginConfig();
+        loginConfig.setAuthMethod(AuthMethod.FORM);
+        loginConfig.setRealmName("default");
+        loginConfig.setFormLoginConfig(form);
+
+        WebResourceCollection webResource = new WebResourceCollection();
+        webResource.setName("ServletTest");
+        Set<String> urlPatterns = new HashSet<String>();
+        urlPatterns.add("/*");
+        webResource.setUrlPatterns(urlPatterns);
+        Set<String> httpMethods = new HashSet<String>();
+        httpMethods.add("GET");
+        httpMethods.add("POST");
+        webResource.setHttpMethods(httpMethods);
+        // This should throw Exception if uncommented
+        //webResource.setHttpMethodOmissions(httpMethods);
+
+        SecurityConstraint securityConstraint = new SecurityConstraint();
+        Set<WebResourceCollection> webResources = new HashSet<WebResourceCollection>();
+        webResources.add(webResource);
+        securityConstraint.setWebResourceCollection(webResources);
+        securityConstraint.setAuthConstraint("administrator");
+        //securityConstraint.setUserDataConstraint(TransportGuarantee.NONE);
+
+        SecurityConfig securityConfig = new SecurityConfig();
+        securityConfig.setLoginConfig(loginConfig);
+        Set<SecurityConstraint> securityConstraints = new HashSet<SecurityConstraint>();
+        securityConstraints.add(securityConstraint);
+        securityConfig.setSecurityConstraints(securityConstraints);
+
+        context.setSecurityConfig(securityConfig);
+
+          /*
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/ServletTest");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(
+                                new InputStreamReader(
+                                yc.getInputStream()));
+
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();   */
+
+        embedded.removeContext(context);
+
+        } catch (Exception ex) {
+            //ignore for now
+            //ex.printStackTrace();
+        }
+
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedVirtualServerHostNameTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedVirtualServerHostNameTest.java
new file mode 100644
index 0000000..bf59095
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedVirtualServerHostNameTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;  
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test for VirtualServerConfig#setHostNames
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedVirtualServerHostNameTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static String contextRoot = "host";
+    static int newPort = 9090;
+    
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+
+        GlassFishRuntime runtime = GlassFishRuntime.bootstrap();
+        GlassFishProperties props = new GlassFishProperties();
+        props.setPort("http-listener", 8080);
+        GlassFish glassfish = runtime.newGlassFish(props);
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+
+    }
+    
+    @Test
+    public void test() throws Exception {
+
+        String virtualServerId = "example";
+        File root = new File("target/classes");
+        VirtualServer virtualServer = embedded.createVirtualServer(virtualServerId, root);
+
+        VirtualServerConfig config = new VirtualServerConfig();
+        config.setHostNames("example.com");
+        virtualServer.setConfig(config);
+        embedded.addVirtualServer(virtualServer);
+
+        VirtualServer vs = embedded.getVirtualServer(virtualServerId);
+        Assert.assertEquals(virtualServerId,vs.getID());
+
+        Context context = (Context) embedded.createContext(root);
+        embedded.addContext(context, contextRoot);
+
+        // curl -i -H 'Host: example.com' http://localhost:8080/
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebAPIDefaultStartTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebAPIDefaultStartTest.java
new file mode 100644
index 0000000..f08a8a6
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebAPIDefaultStartTest.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URL;
+import java.net.URLConnection;
+import org.apache.catalina.logger.SystemOutLogger;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer#start correctly starts the server with default 8080 port
+ * if no port is previously defined.
+ *
+ * @author Amy Roh
+ */
+public class EmbeddedWebAPIDefaultStartTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ Test Embedded Web API Default Start ");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+    }
+    
+    @Test
+    public void testDefaultStart() throws Exception {
+
+        HttpListener httpListener = new HttpListener();
+        httpListener.setPort(8080);
+        httpListener.setId("embedded-listener-1");
+        embedded.addWebListener(httpListener);
+
+        List<WebListener> listenerList = new ArrayList(embedded.getWebListeners());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        Deployer deployer = glassfish.getDeployer();
+
+        URL source = WebHello.class.getClassLoader().getResource(
+                "org/glassfish/tests/embedded/web/WebHello.class");
+        String p = source.getPath().substring(0, source.getPath().length() -
+                "org/glassfish/tests/embedded/web/WebHello.class".length());
+        File path = new File(p).getParentFile().getParentFile();
+
+        String name = null;
+
+        if (path.getName().lastIndexOf('.') != -1) {
+            name = path.getName().substring(0, path.getName().lastIndexOf('.'));
+        } else {
+            name = path.getName();
+        }
+
+        System.out.println("Deploying " + path + ", name = " + name);
+
+        String appName = deployer.deploy(path.toURI(), "--name=" + name);
+
+        System.out.println("Deployed " + appName);
+
+        Assert.assertTrue(appName != null);
+
+        URL servlet = new URL("http://localhost:8080/classes/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+
+        Thread.sleep(1000);
+        
+        if (appName!=null)
+            deployer.undeploy(appName);
+    }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebAPITest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebAPITest.java
new file mode 100644
index 0000000..a3be7cd
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebAPITest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import org.apache.catalina.logger.SystemOutLogger;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests creating a port using WebContainer#createWeblistener & WebListener#setPort.
+ * Checks if network listener is correctly added and deployment suceeds on the port specified.
+ *
+ * @author Amy Roh
+ */
+public class EmbeddedWebAPITest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static String contextRoot = "test";
+
+    @BeforeClass
+    public static void setupServer() throws GlassFishException {
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ Test Embedded Web API");
+        System.out.println("Starting Web "+embedded);
+        embedded.setLogLevel(Level.INFO);
+    }
+    
+    @Test
+    public void testEmbeddedWebAPI() throws Exception {
+
+        HttpListener httpListener = new HttpListener();
+        httpListener.setPort(8080);
+        httpListener.setId("embedded-listener-1");
+        embedded.addWebListener(httpListener);
+
+        List<WebListener> listenerList = new ArrayList(embedded.getWebListeners());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        WebListener testListener = embedded.createWebListener("test-listener", HttpListener.class);
+        testListener.setPort(9090);
+        embedded.addWebListener(testListener);
+
+        listenerList = new ArrayList(embedded.getWebListeners());
+        System.out.println("Network listener size after creation " + listenerList.size());
+        Assert.assertTrue(listenerList.size()==2);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        File f = new File("target/classes");
+        String virtualServerId = "embedded-server";
+        VirtualServer vs = (VirtualServer)
+                embedded.createVirtualServer(virtualServerId, f);
+        VirtualServerConfig config = new VirtualServerConfig();
+        config.setHostNames("localhost");
+        vs.setConfig(config);
+        embedded.addVirtualServer(vs);
+
+        vs = embedded.getVirtualServer(virtualServerId);
+        Assert.assertEquals(virtualServerId,vs.getID());
+
+        //Context context = (Context) embedded.createContext(root, null);
+        //defaultVirtualServer.addContext(context, "");
+
+        Deployer deployer = glassfish.getDeployer();
+
+        URL source = WebHello.class.getClassLoader().getResource(
+                "org/glassfish/tests/embedded/web/WebHello.class");
+        String p = source.getPath().substring(0, source.getPath().length() -
+                "org/glassfish/tests/embedded/web/WebHello.class".length());
+        File path = new File(p).getParentFile().getParentFile();
+
+        String name = null;
+
+        if (path.getName().lastIndexOf('.') != -1) {
+            name = path.getName().substring(0, path.getName().lastIndexOf('.'));
+        } else {
+            name = path.getName();
+        }
+
+        System.out.println("Deploying " + path + ", name = " + name);
+
+        String appName = deployer.deploy(path.toURI(), "--contextroot", contextRoot, "--name=" + name);
+
+        System.out.println("Deployed " + appName);
+
+        Assert.assertTrue(appName != null);
+
+        URL servlet = new URL("http://localhost:8080/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+
+        embedded.removeWebListener(testListener);
+
+        listenerList = new ArrayList(embedded.getWebListeners());
+        System.out.println("Network listener size after creation " + listenerList.size());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        Thread.sleep(1000);
+
+        if (appName!=null)
+            deployer.undeploy(appName);
+     }
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebTest.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebTest.java
new file mode 100644
index 0000000..b008dfb
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/EmbeddedWebTest.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.logging.Level;
+import java.util.ArrayList;
+import java.util.List;
+import org.glassfish.embeddable.*;
+import org.glassfish.embeddable.web.*;  
+import org.glassfish.embeddable.web.config.*;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests WebContainer
+ * 
+ * @author Amy Roh
+ */
+public class EmbeddedWebTest {
+
+    static GlassFish glassfish;
+    static WebContainer embedded;
+    static int newPort = 9090;
+    static String contextRoot = "test";
+    static File root;
+    static WebContainerConfig config;
+    
+    @BeforeClass
+    public static void setupServer() throws Exception {
+
+        glassfish = GlassFishRuntime.bootstrap().newGlassFish();
+        glassfish.start();
+        embedded = glassfish.getService(WebContainer.class);
+        System.out.println("================ EmbeddedWeb Test");
+        System.out.println("Starting Web "+embedded);
+        root = new File("target/classes");
+        configure();
+        
+    }
+
+    private static void configure() throws Exception {
+
+        config = new WebContainerConfig();
+        embedded.setLogLevel(Level.INFO);
+        config.setDocRootDir(root);
+        System.out.println("Added Web with base directory "+root.getAbsolutePath());
+        config.setListenerName("embedded-listener");
+        config.setPort(8080);
+        File defaultWebXml = new File(root+"/org/glassfish/tests/webapi/my-default-web.xml");
+        config.setDefaultWebXml(defaultWebXml.toURL());
+        System.out.println("Using default-web.xml "+defaultWebXml.getAbsolutePath());
+        config.setVirtualServerId("server");
+        embedded.setConfiguration(config);
+
+    }
+
+    @Test
+    public void test() throws Exception {
+
+        WebListener testListener = embedded.createWebListener("test-listener", HttpListener.class);
+        testListener.setPort(newPort);
+        WebListener[] webListeners = new HttpListener[1];
+        webListeners[0] = testListener;
+
+        String virtualServerId = "embedded-server";
+        VirtualServer virtualServer = (VirtualServer)
+                embedded.createVirtualServer(virtualServerId, root, webListeners);
+        embedded.addVirtualServer(virtualServer);
+
+        config.setVirtualServerId(virtualServerId);
+        config.setHostNames("localhost");
+        embedded.setConfiguration(config);
+
+        ArrayList<WebListener> listenerList = new ArrayList(embedded.getWebListeners());
+        System.out.println("Network listener size after creation " + listenerList.size());
+        Assert.assertTrue(listenerList.size()==2);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        VirtualServer vs = embedded.getVirtualServer(virtualServerId);
+        Assert.assertEquals(virtualServerId,vs.getID());                     
+
+        Context context = (Context) embedded.createContext(root);
+        //embedded.addContext(context, contextRoot);
+        virtualServer.addContext(context, contextRoot);
+ 
+        URL servlet = new URL("http://localhost:"+newPort+"/"+contextRoot+"/hello");
+        URLConnection yc = servlet.openConnection();
+        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+        StringBuilder sb = new StringBuilder();
+        String inputLine;
+        while ((inputLine = in.readLine()) != null){
+            sb.append(inputLine);
+        }
+        in.close();
+        System.out.println(inputLine);
+        Assert.assertEquals("Hello World!", sb.toString());
+
+        System.out.println("Removing web listener "+testListener.getId());
+        embedded.removeWebListener(testListener);                       
+
+        listenerList = new ArrayList(embedded.getWebListeners());
+        System.out.println("Network listener size after deletion " + listenerList.size());
+        Assert.assertTrue(listenerList.size()==1);
+        for (WebListener listener : embedded.getWebListeners())
+            System.out.println("Web listener "+listener.getId()+" "+listener.getPort());
+
+        virtualServer.removeContext(context);
+
+    } 
+
+    @AfterClass
+    public static void shutdownServer() throws GlassFishException {
+        System.out.println("Stopping server " + glassfish);
+        if (glassfish != null) {
+            glassfish.stop();
+            glassfish.dispose();
+            glassfish = null;
+        }
+    }
+    
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/MyServlet.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/MyServlet.java
new file mode 100644
index 0000000..b42a096
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/MyServlet.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.*;
+
+public class MyServlet extends HttpServlet {
+
+    public MyServlet() {
+        System.out.println("Servlet MyServlet initialized");
+    }
+
+    public void service(ServletRequest req, ServletResponse res)
+            throws IOException, ServletException {
+        if (!"def".equals(req.getAttribute("abc"))) {
+            throw new ServletException("Missing ServletRequest parameter");
+        } else {
+            PrintWriter pw = res.getWriter();
+            try {
+                pw.println("Hello World!");
+            } catch(Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/MyServletContextListener.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/MyServletContextListener.java
new file mode 100755
index 0000000..3e69d6b
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/MyServletContextListener.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import java.util.*;
+import javax.servlet.*;
+
+public class MyServletContextListener implements ServletContextListener {
+
+    /**
+     * Receives notification that the web application initialization
+     * process is starting.
+     *
+     * @param sce The servlet context event
+     */
+    public void contextInitialized(ServletContextEvent sce) {
+        sce.getServletContext().addListener("org.glassfish.tests.embedded.web.NewServletRequestListener");
+    }
+
+    /**
+     * Receives notification that the servlet context is about to be shut down.
+     *
+     * @param sce The servlet context event
+     */
+    public void contextDestroyed(ServletContextEvent sce) {
+        // Do nothing
+    }
+
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewFilter.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewFilter.java
new file mode 100644
index 0000000..a7900d3
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewFilter.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import javax.servlet.*;
+
+public class NewFilter implements Filter {
+
+    String filterInitParam;
+
+    public void init(FilterConfig filterConfig) throws ServletException {
+        filterInitParam = filterConfig.getInitParameter("filterInitName");
+    }
+
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain)
+            throws IOException, ServletException {
+        request.setAttribute("filterInitName", filterInitParam);
+        chain.doFilter(request, response);
+    }
+
+    public void destroy() {
+        // do nothing
+    }
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewFilterServlet.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewFilterServlet.java
new file mode 100644
index 0000000..7ac554b
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewFilterServlet.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+public class NewFilterServlet extends HttpServlet {
+
+    public void service(ServletRequest req, ServletResponse res)
+            throws IOException, ServletException {
+        if (!"servletInitValue".equals(getServletConfig().getInitParameter(
+                        "servletInitName"))) {
+            throw new ServletException("Missing servlet init param");
+        }
+
+        if (!"filterInitValue".equals(req.getAttribute("filterInitName"))) {
+            throw new ServletException("Missing filter init param");
+        }
+
+    }
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewServlet.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewServlet.java
new file mode 100644
index 0000000..c559294
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewServlet.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.*;
+
+//@WebServlet(urlPatterns={"/new"})
+public class NewServlet extends HttpServlet {
+
+    private String initParamValue;
+    private String myParamValue;
+
+
+    public NewServlet() {
+        System.out.println("Servlet NewServlet initialized");
+    }
+
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        PrintWriter pw = res.getWriter();
+        try {
+            pw.println("Hello World!");
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /*public void setMyParameter(String value) {
+        myParamValue = value;
+    }
+
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        initParamValue = config.getInitParameter("servletInitParamName");
+    }
+
+        public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        PrintWriter pw = res.getWriter();
+        try {
+            pw.println("Hello World!");
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void service(ServletRequest req, ServletResponse res)
+            throws IOException, ServletException {
+        if (!"myServletParamValue".equals(myParamValue)) {
+            throw new ServletException("Wrong servlet instance");
+        }
+
+        if (!"servletInitParamValue".equals(initParamValue)) {
+            throw new ServletException("Missing servlet init param");
+        }
+
+        if (!"myFilterParamValue".equals(
+                req.getAttribute("myFilterParamName"))) {
+            throw new ServletException("Wrong filter instance");
+        }
+
+        if (!"filterInitParamValue".equals(
+                req.getAttribute("filterInitParamName"))) {
+            throw new ServletException("Missing filter init param");
+        }
+    }*/
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewServletRequestListener.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewServletRequestListener.java
new file mode 100644
index 0000000..6199a6e
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/NewServletRequestListener.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.*;
+import javax.servlet.*;
+
+public class NewServletRequestListener implements ServletRequestListener {
+
+    public void requestInitialized(ServletRequestEvent sre) {
+        sre.getServletRequest().setAttribute("abc", "def");
+    }
+
+    public void requestDestroyed(ServletRequestEvent sre) {
+        // Do nothing
+    }
+}
diff --git a/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/WebHello.java b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/WebHello.java
new file mode 100644
index 0000000..f7e2ecc
--- /dev/null
+++ b/appserver/tests/embedded/web/web-api/src/test/java/org/glassfish/tests/embedded/web/WebHello.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.annotation.Resource;
+
+@WebServlet(urlPatterns={"/hello"})
+public class WebHello extends HttpServlet {
+
+    public WebHello() {
+        System.out.println("Servlet WEB-HELLO initialized");
+    }
+   
+    public void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        PrintWriter pw = res.getWriter();
+        try {
+            pw.println("Hello World!");
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/appserver/tests/embedded/web/web-war/pom.xml b/appserver/tests/embedded/web/web-war/pom.xml
new file mode 100644
index 0000000..eb418d2
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests</groupId>
+    <artifactId>embedded-web-war</artifactId>
+    <packaging>pom</packaging>
+    <name>GlassFish Embedded Web war test</name>
+
+    <modules>
+        <module>web-fragment1</module>
+        <module>web-fragment2</module>
+        <module>web-fragment3</module>
+        <module>war</module>
+        <module>test</module>
+    </modules>
+</project>
diff --git a/appserver/tests/embedded/web/web-war/test/pom.xml b/appserver/tests/embedded/web/web-war/test/pom.xml
new file mode 100644
index 0000000..4300fef
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/test/pom.xml
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded-web-war</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests.embedded-web-war</groupId>
+    <artifactId>test</artifactId>
+    <name>GlassFish Embedded Web war test: test</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.6.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <systemProperties>
+                        <property>
+                            <name>buildDir</name>
+                            <value>${project.build.outputDirectory}</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>unpack</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.glassfish.distributions</groupId>
+                                    <artifactId>web</artifactId>
+                                    <version>${project.version}</version>
+                                    <type>zip</type>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <forkMode>always</forkMode>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>${servlet-api.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.extras</groupId>
+            <artifactId>glassfish-embedded-web</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.extras</groupId>
+            <artifactId>glassfish-embedded-shell</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.core</groupId>
+            <artifactId>kernel</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>        
+        <dependency>
+            <groupId>org.glassfish.security</groupId>
+            <artifactId>inmemory.jacc.provider</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>        
+        <dependency>
+            <groupId>org.glassfish.admin</groupId>
+            <artifactId>config-api</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.web</groupId>
+            <artifactId>webtier-all</artifactId>
+            <type>pom</type>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>  
+        <dependency>
+            <groupId>org.glassfish.transaction</groupId>
+            <artifactId>jta</artifactId>
+            <version>5.0.1-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>        
+        <dependency>
+            <groupId>org.glassfish.web</groupId>
+            <artifactId>web-embed-impl</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+          <groupId>org.glassfish</groupId>
+          <artifactId>javax.faces</artifactId>
+          <version>2.1.6</version>
+            <scope>test</scope>
+        </dependency>
+
+   </dependencies>
+</project>
diff --git a/appserver/tests/embedded/web/web-war/test/src/test/java/org/glassfish/tests/embedded/webwar/EmbeddedTest.java b/appserver/tests/embedded/web/web-war/test/src/test/java/org/glassfish/tests/embedded/webwar/EmbeddedTest.java
new file mode 100644
index 0000000..9fa585d
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/test/src/test/java/org/glassfish/tests/embedded/webwar/EmbeddedTest.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.webwar;
+
+import java.util.*;
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.glassfish.grizzly.config.dom.NetworkConfig;
+import org.glassfish.grizzly.config.dom.NetworkListener;
+import org.glassfish.internal.embedded.Server;
+import org.glassfish.internal.embedded.LifecycleException;
+import org.glassfish.internal.embedded.EmbeddedContainer;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.internal.embedded.EmbeddedDeployer;
+import org.glassfish.internal.embedded.Port;
+import org.glassfish.internal.embedded.ScatteredArchive;
+import org.glassfish.internal.embedded.ScatteredArchive.Builder;
+import org.glassfish.internal.embedded.ContainerBuilder;
+import org.glassfish.internal.embedded.admin.AdminInfo;
+import org.glassfish.internal.embedded.admin.EmbeddedAdminContainer;
+import org.glassfish.internal.embedded.admin.CommandExecution;
+import org.glassfish.internal.embedded.admin.CommandParameters;
+import org.glassfish.api.embedded.web.EmbeddedWebContainer;
+import org.glassfish.api.ActionReport.MessagePart;
+import org.glassfish.api.container.Sniffer;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.io.File;
+import java.net.URL;
+import java.net.URLConnection;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import org.glassfish.api.admin.ServerEnvironment;
+
+public class EmbeddedTest {
+
+    private static Port http=null;
+    private static Server server = null;
+
+    @BeforeClass
+    public static void setup() {
+        Server.Builder builder = new Server.Builder("build");
+
+        server = builder.build();
+        NetworkConfig nc = server.getHabitat().getService(NetworkConfig.class,
+                ServerEnvironment.DEFAULT_INSTANCE_NAME);
+        List<NetworkListener> listeners = nc.getNetworkListeners().getNetworkListener();
+        System.out.println("Network listener size before creation " + listeners.size());
+        for (NetworkListener nl : listeners) {
+            System.out.println("Network listener " + nl.getPort());
+        }
+        try {
+            http = server.createPort(8080);
+            ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
+            server.addContainer(b);
+            EmbeddedWebContainer embedded = (EmbeddedWebContainer) b.create(server);
+            embedded.bind(http, "http");
+        } catch(IOException e) {
+            throw new RuntimeException(e);
+        }
+        listeners = nc.getNetworkListeners().getNetworkListener();
+        System.out.println("Network listener size after creation " + listeners.size());
+        Assert.assertTrue(listeners.size() == 1);
+        for (NetworkListener nl : listeners) {
+            System.out.println("Network listener " + nl.getPort());
+        }
+        Collection<NetworkListener> cnl = server.getHabitat().getAllServices(NetworkListener.class);
+        System.out.println("Network listener size after creation " + cnl.size());
+        for (NetworkListener nl : cnl) {
+            System.out.println("Network listener " + nl.getPort());
+        }
+
+        server.addContainer(ContainerBuilder.Type.all);
+    }    
+
+    @Test
+    public void testWeb() throws Exception {
+        System.out.println("Starting Web " + server);
+        ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
+        System.out.println("builder is " + b);
+        server.addContainer(b);
+        EmbeddedDeployer deployer = server.getDeployer();
+        System.out.println("Added Web");
+
+        String testClass = "org/glassfish/tests/embedded/webwar/EmbeddedTest.class";
+        URL source = this.getClass().getClassLoader().getResource(testClass);
+        String p = source.getPath().substring(0, source.getPath().length()-testClass.length()) +
+            "../../../war/target/test-war.war";
+
+        System.out.println("Root is " + p);
+        DeployCommandParameters dp = new DeployCommandParameters(new File(p));
+
+        System.out.println("Deploying " + p);
+        String appName = null;
+        try {
+            appName = deployer.deploy(new File(p), dp);
+            System.out.println("Deployed " + appName);
+            Assert.assertTrue(appName != null);
+            try {
+                URL servlet = new URL("http://localhost:8080/test-war/");
+                URLConnection yc = servlet.openConnection();
+                BufferedReader in = new BufferedReader(
+                                        new InputStreamReader(
+                                        yc.getInputStream()));
+                String inputLine = in.readLine();
+                if (inputLine != null)
+                    System.out.println(inputLine);
+                Assert.assertEquals(inputLine.trim(), "filterMessage=213");
+                in.close();
+            } catch(Exception e) {
+                e.printStackTrace();
+                throw e;
+            }
+        } catch(Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+        if (appName!=null)
+            deployer.undeploy(appName, null);
+
+    }
+
+    public static void  close() throws LifecycleException {
+        if (http!=null) {
+            http.close();
+            http=null;
+        }
+        System.out.println("Stopping server " + server);
+        if (server!=null) {
+            server.stop();
+            server=null;
+        }
+    }
+}
diff --git a/appserver/tests/embedded/web/web-war/war/pom.xml b/appserver/tests/embedded/web/web-war/war/pom.xml
new file mode 100644
index 0000000..8fc2ef2
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/war/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded-web-war</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests.embedded-web-war</groupId>
+    <artifactId>test-war</artifactId>
+    <packaging>war</packaging>
+    <name>GlassFish Embedded Web war test: war</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>${servlet-api.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.tests.embedded-web-war</groupId>
+            <artifactId>web-fragment1</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tests.embedded-web-war</groupId>
+            <artifactId>web-fragment2</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.tests.embedded-web-war</groupId>
+            <artifactId>web-fragment3</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+   </dependencies>
+</project>
diff --git a/appserver/tests/embedded/web/web-war/war/src/main/java/org/glassfish/tests/embedded/webwar/TestServlet.java b/appserver/tests/embedded/web/web-war/war/src/main/java/org/glassfish/tests/embedded/webwar/TestServlet.java
new file mode 100644
index 0000000..d315acf
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/war/src/main/java/org/glassfish/tests/embedded/webwar/TestServlet.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.webwar;
+
+import java.io.*;
+import java.util.Enumeration;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.servlet.annotation.WebServlet;
+
+@WebServlet("/")
+public class TestServlet extends HttpServlet {
+    protected void doGet(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+        String message = "filterMessage=" + req.getAttribute("filterMessage");
+        res.getWriter().println(message);
+    }
+}
diff --git a/appserver/tests/embedded/web/web-war/war/src/main/webapp/WEB-INF/web.xml b/appserver/tests/embedded/web/web-war/war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..0f79924
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/war/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+  <absolute-ordering>
+    <name>A</name>
+    <others/>
+    <name>B</name>
+  </absolute-ordering>
+</web-app>
diff --git a/appserver/tests/embedded/web/web-war/web-fragment1/pom.xml b/appserver/tests/embedded/web/web-war/web-fragment1/pom.xml
new file mode 100644
index 0000000..6f3786f
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment1/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded-web-war</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests.embedded-web-war</groupId>
+    <artifactId>web-fragment1</artifactId>
+    <packaging>jar</packaging>
+    <name>GlassFish Embedded Web war test: web-fragment1</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+   </dependencies>
+</project>
diff --git a/appserver/tests/embedded/web/web-war/web-fragment1/src/main/java/org/glassfish/tests/embedded/webwar/webfragment1/WFTestFilter.java b/appserver/tests/embedded/web/web-war/web-fragment1/src/main/java/org/glassfish/tests/embedded/webwar/webfragment1/WFTestFilter.java
new file mode 100644
index 0000000..467d7be
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment1/src/main/java/org/glassfish/tests/embedded/webwar/webfragment1/WFTestFilter.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.webwar.webfragment1;
+
+import java.io.IOException;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+
+@WebFilter(urlPatterns={ "/" }, dispatcherTypes= { DispatcherType.REQUEST })
+public class WFTestFilter implements Filter {
+    public void init(FilterConfig filterConfig) throws ServletException {
+        System.out.println(">>> WFTestFilter.init");
+    }   
+
+    public void doFilter(ServletRequest req, ServletResponse res,
+            FilterChain chain) throws IOException, ServletException {
+
+        System.out.println(">>> WFTestFilter.doFilter");
+        String filterMessage = (String)req.getAttribute("filterMessage");
+        if (filterMessage == null) {
+            filterMessage = "";
+        }
+        filterMessage += "1";
+
+        req.setAttribute("filterMessage", filterMessage);
+        chain.doFilter(req, res);
+    }
+
+    public void destroy() {
+        System.out.println(">>> WFTestFilter.destroy");
+    }
+}
diff --git a/appserver/tests/embedded/web/web-war/web-fragment2/pom.xml b/appserver/tests/embedded/web/web-war/web-fragment2/pom.xml
new file mode 100644
index 0000000..8eefd00
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment2/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded-web-war</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests.embedded-web-war</groupId>
+    <artifactId>web-fragment2</artifactId>
+    <packaging>jar</packaging>
+    <name>GlassFish Embedded Web war test: web-fragment2</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>${servlet-api.version}</version>
+            <scope>provided</scope>
+        </dependency>
+   </dependencies>
+</project>
diff --git a/appserver/tests/embedded/web/web-war/web-fragment2/src/main/java/org/glassfish/tests/embedded/webwar/webfragment2/WFTestFilter2.java b/appserver/tests/embedded/web/web-war/web-fragment2/src/main/java/org/glassfish/tests/embedded/webwar/webfragment2/WFTestFilter2.java
new file mode 100644
index 0000000..3d83ce7
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment2/src/main/java/org/glassfish/tests/embedded/webwar/webfragment2/WFTestFilter2.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.webwar.webfragment2;
+
+import java.io.IOException;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+
+@WebFilter(urlPatterns={ "/abc" }, dispatcherTypes= { DispatcherType.REQUEST })
+public class WFTestFilter2 implements Filter {
+    public void init(FilterConfig filterConfig) throws ServletException {
+        System.out.println(">>> WFTestFilter2.init");
+    }   
+
+    public void doFilter(ServletRequest req, ServletResponse res,
+            FilterChain chain) throws IOException, ServletException {
+
+        System.out.println(">>> WFTestFilter2.doFilter");
+        String filterMessage = (String)req.getAttribute("filterMessage");
+        if (filterMessage == null) {
+            filterMessage = "";
+        }
+        filterMessage += "2";
+
+        req.setAttribute("filterMessage", filterMessage);
+        chain.doFilter(req, res);
+    }
+
+    public void destroy() {
+        System.out.println(">>> WFTestFilter2.destroy");
+    }
+}
diff --git a/appserver/tests/embedded/web/web-war/web-fragment2/src/main/java/org/glassfish/tests/embedded/webwar/webfragment2/WFTestFilter2B.java b/appserver/tests/embedded/web/web-war/web-fragment2/src/main/java/org/glassfish/tests/embedded/webwar/webfragment2/WFTestFilter2B.java
new file mode 100644
index 0000000..ae5104c
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment2/src/main/java/org/glassfish/tests/embedded/webwar/webfragment2/WFTestFilter2B.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.webwar.webfragment2;
+
+import java.io.IOException;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+
+@WebFilter(urlPatterns={ "/" }, dispatcherTypes= { DispatcherType.REQUEST })
+public class WFTestFilter2B implements Filter {
+    public void init(FilterConfig filterConfig) throws ServletException {
+        System.out.println(">>> WFTestFilter2B.init");
+    }   
+
+    public void doFilter(ServletRequest req, ServletResponse res,
+            FilterChain chain) throws IOException, ServletException {
+
+        System.out.println(">>> WFTestFilter2B.doFilter");
+        String filterMessage = (String)req.getAttribute("filterMessage");
+        if (filterMessage == null) {
+            filterMessage = "";
+        }
+        filterMessage += "B";
+
+        req.setAttribute("filterMessage", filterMessage);
+        chain.doFilter(req, res);
+    }
+
+    public void destroy() {
+        System.out.println(">>> WFTestFilter2B.destroy");
+    }
+}
diff --git a/appserver/tests/embedded/web/web-war/web-fragment2/src/main/resources/META-INF/web-fragment.xml b/appserver/tests/embedded/web/web-war/web-fragment2/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 0000000..3de1c64
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment2/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-fragment metadata-complete="true">
+  <name>A</name>
+  <filter>
+    <icon/>
+    <filter-name>wftest2.WFTestFilter2</filter-name>
+    <filter-class>org.glassfish.tests.embedded.webwar.webfragment2.WFTestFilter2</filter-class>
+  </filter>
+  <filter-mapping>
+    <filter-name>wftest2.WFTestFilter2</filter-name>
+    <url-pattern>/</url-pattern>
+  </filter-mapping>
+</web-fragment>
diff --git a/appserver/tests/embedded/web/web-war/web-fragment3/pom.xml b/appserver/tests/embedded/web/web-war/web-fragment3/pom.xml
new file mode 100644
index 0000000..ff99fed
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment3/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.tests</groupId>
+        <artifactId>embedded-web-war</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.glassfish.tests.embedded-web-war</groupId>
+    <artifactId>web-fragment3</artifactId>
+    <packaging>jar</packaging>
+    <name>GlassFish Embedded Web war test: web-fragment3</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>${servlet-api.version}</version>
+            <scope>provided</scope>
+        </dependency>
+   </dependencies>
+</project>
diff --git a/appserver/tests/embedded/web/web-war/web-fragment3/src/main/java/org/glassfish/tests/embedded/webwar/webfragment3/WFTestFilter3.java b/appserver/tests/embedded/web/web-war/web-fragment3/src/main/java/org/glassfish/tests/embedded/webwar/webfragment3/WFTestFilter3.java
new file mode 100644
index 0000000..42e2ce4
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment3/src/main/java/org/glassfish/tests/embedded/webwar/webfragment3/WFTestFilter3.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded.webwar.webfragment3;
+
+import java.io.IOException;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+
+@WebFilter(urlPatterns={ "/" }, dispatcherTypes= { DispatcherType.REQUEST })
+public class WFTestFilter3 implements Filter {
+    public void init(FilterConfig filterConfig) throws ServletException {
+        System.out.println(">>> WFTestFilter3.init");
+    }   
+
+    public void doFilter(ServletRequest req, ServletResponse res,
+            FilterChain chain) throws IOException, ServletException {
+
+        System.out.println(">>> WFTestFilter3.doFilter");
+        String filterMessage = (String)req.getAttribute("filterMessage");
+        if (filterMessage == null) {
+            filterMessage = "";
+        }
+        filterMessage += "3";
+
+        req.setAttribute("filterMessage", filterMessage);
+        chain.doFilter(req, res);
+    }
+
+    public void destroy() {
+        System.out.println(">>> WFTestFilter3.destroy");
+    }
+}
diff --git a/appserver/tests/embedded/web/web-war/web-fragment3/src/main/resources/META-INF/web-fragment.xml b/appserver/tests/embedded/web/web-war/web-fragment3/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 0000000..f562d60
--- /dev/null
+++ b/appserver/tests/embedded/web/web-war/web-fragment3/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<web-fragment>
+  <name>B</name>
+</web-fragment>
diff --git a/appserver/tests/embedded/wrapper/pom.xml b/appserver/tests/embedded/wrapper/pom.xml
new file mode 100644
index 0000000..2b9dd4c
--- /dev/null
+++ b/appserver/tests/embedded/wrapper/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.glassfish.test</groupId>
+    <artifactId>test-wrapper</artifactId>
+    <version>5.0.1-SNAPSHOT</version>
+    <name>Embedded GlassFish Wrapper</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.common</groupId>
+            <artifactId>glassfish-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/tests/embedded/wrapper/src/main/java/org/glassfish/tests/embedded/EmbeddedMain.java b/appserver/tests/embedded/wrapper/src/main/java/org/glassfish/tests/embedded/EmbeddedMain.java
new file mode 100644
index 0000000..8b6f8c5
--- /dev/null
+++ b/appserver/tests/embedded/wrapper/src/main/java/org/glassfish/tests/embedded/EmbeddedMain.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.tests.embedded;
+
+import org.glassfish.internal.embedded.*;
+
+import java.io.File;
+
+
+/** A 'wrapper' class that is used by QA to run tests on embedded. This class is used to start the domain
+ * in embedded mode from asadmin cli
+ *
+ */
+
+public class EmbeddedMain {
+    public static void main(String[] args) {
+
+       String installRoot = System.getenv("S1AS_HOME");
+       if (installRoot == null) {
+           System.out.println("Environment variable S1AS_HOME not defined - it must point to the glassfish install root");
+           return;
+       }
+       String instanceRoot = installRoot + "/domains/domain1";
+       String domainXml = instanceRoot + "/config/domain.xml";
+
+        System.setProperty("com.sun.aas.instanceRootURI", "file:" + instanceRoot);
+        //System.setProperty("com.sun.aas.installRoot", installRoot );
+//        System.setProperty("com.sun.aas.instanceRoot", instanceRoot );
+
+       EmbeddedFileSystem efs =
+          new EmbeddedFileSystem.Builder().
+          installRoot(new File(installRoot), true).
+          instanceRoot(new File(instanceRoot)).
+          configurationFile(new File(domainXml), false).autoDelete(false).build();
+
+        Server.Builder builder = new Server.Builder("asadmin");
+
+        Server server = builder.embeddedFileSystem(efs).build();
+        server.addContainer(ContainerBuilder.Type.all);
+    }
+}
+
+