import org.glassfish.embeddable.*; import org.glassfish.embeddable.web.*; import java.io.*; import java.net.*; import java.net.*; import java.io.*; public class EJBTest { public static void main(String... args) throws Exception { GlassFishRuntime gfRuntime = GlassFishRuntime.bootstrap(); //String instanceRoot = "/Users/Amy/glassfish3/glassfish/domains/domain1"; GlassFishProperties gfProps = new GlassFishProperties(); //gfProps.setInstanceRoot(instanceRoot); String domain = "file:///tmp/domain5351655843759277784xml"; gfProps.setConfigFileURI(domain); GlassFish glassfish = gfRuntime.newGlassFish(gfProps); glassfish.start(); Deployer deployer = glassfish.getDeployer(); String appName = deployer.deploy(new File("/Users/Amy/glassfish-appserv-tests/appserv-tests/build/module/archive/ejb-ejb31-embedded-ejbwinwar-web.war")); String url = "http://localhost:8080/" + "ejb-ejb31-embedded-ejbwinwar-web/mytest"; System.out.println("invoking webclient servlet at " + url); URL u = new URL(url); HttpURLConnection c1 = (HttpURLConnection)u.openConnection(); int code = c1.getResponseCode(); InputStream is = c1.getInputStream(); BufferedReader input = new BufferedReader (new InputStreamReader(is)); String line = null; while((line = input.readLine()) != null) System.out.println(line); if(code != 200) { throw new RuntimeException("Incorrect return code: " + code); } System.out.println("Successfully deployed [ " + appName + " ]"); System.out.println("Press any key to exit."); new BufferedReader(new InputStreamReader(System.in)).readLine(); glassfish.dispose(); } }