You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2015/11/07 03:32:39 UTC

tomee git commit: Delegate RemoteServer.destroy() to usage

Repository: tomee
Updated Branches:
  refs/heads/master eec7ca53e -> 2cef2ddbd


Delegate RemoteServer.destroy() to usage


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2cef2ddb
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2cef2ddb
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2cef2ddb

Branch: refs/heads/master
Commit: 2cef2ddbd3348c9001cba74201db914521e7ce94
Parents: eec7ca5
Author: andygumbrecht@apache.org <an...@gmx.de>
Authored: Sat Nov 7 03:30:06 2015 +0100
Committer: andygumbrecht@apache.org <an...@gmx.de>
Committed: Sat Nov 7 03:30:06 2015 +0100

----------------------------------------------------------------------
 .../arquillian/remote/RemoteTomEEContainer.java |   9 +-
 .../arquillian/webapp/TomEEWebappContainer.java |  11 +-
 .../org/apache/openejb/config/RemoteServer.java |  34 +-
 .../openejb/maven/plugin/AbstractTomEEMojo.java |   3 +-
 .../openejb/maven/plugin/runner/ExecRunner.java |   9 +-
 .../openejb/tck/impl/ContainersImplTomEE.java   | 335 ++++++++++---------
 .../openejb/tck/impl/FullRestartContainer.java  | 273 +++++++--------
 .../apache/tomee/RemoteTomEEEJBContainer.java   | 331 +++++++++---------
 8 files changed, 525 insertions(+), 480 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEContainer.java b/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEContainer.java
index 110e113..e5ce343 100644
--- a/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEContainer.java
+++ b/arquillian/arquillian-tomee-remote/src/main/java/org/apache/tomee/arquillian/remote/RemoteTomEEContainer.java
@@ -116,7 +116,14 @@ public class RemoteTomEEContainer extends TomEEContainer<RemoteTomEEConfiguratio
 
             container = new RemoteServer();
             container.setPortStartup(httpPort);
-            container.start(args(), "start", true);
+
+            try {
+                container.start(args(), "start", true);
+            } catch (final Exception e) {
+                container.destroy();
+                throw e;
+            }
+
             container.killOnExit();
 
             if (configuration.getProperties() != null) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappContainer.java b/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappContainer.java
index 90ca223..bfd8fc4 100644
--- a/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappContainer.java
+++ b/arquillian/arquillian-tomee-webapp-remote/src/main/java/org/apache/tomee/arquillian/webapp/TomEEWebappContainer.java
@@ -146,7 +146,13 @@ public class TomEEWebappContainer extends TomEEContainer<TomEEWebappConfiguratio
 
                 final RemoteServer tmpContainer = new RemoteServer();
                 tmpContainer.setPortStartup(httpPort);
-                tmpContainer.start();
+
+                try {
+                    tmpContainer.start();
+                } catch (final Exception e) {
+                    tmpContainer.destroy();
+                    throw e;
+                }
 
                 final URL url = new URL(baseUrl);
                 logger.info("Calling TomEE Installer Servlet on " + url);
@@ -179,7 +185,8 @@ public class TomEEWebappContainer extends TomEEContainer<TomEEWebappConfiguratio
                 "-Dorg.apache.openejb.servlet.filters=" + ArquillianFilterRunner.class.getName() + "=" + ServletMethodExecutor.ARQUILLIAN_SERVLET_MAPPING), "start", true);
             container.killOnExit();
         } catch (final Exception e) {
-            throw new LifecycleException("Unable to start remote container", e);
+            if(null != container){container.destroy();}
+            throw new LifecycleException("Unable to start remote container on port: " + httpPort, e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
index 5de85cc..f024610 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
@@ -37,6 +37,8 @@ import java.util.Properties;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * NOTE: Do not add inner or anonymous classes or a dependency without updating ExecMojo
@@ -108,7 +110,13 @@ public class RemoteServer {
     public static void main(final String[] args) {
         assert args.length > 0 : "no arguments supplied: valid arguments are 'start' or 'stop'";
         if (args[0].equalsIgnoreCase(START)) {
-            new RemoteServer().start();
+            final RemoteServer remoteServer = new RemoteServer();
+            try {
+                remoteServer.start();
+            } catch (final Exception e) {
+                remoteServer.destroy();
+                throw e;
+            }
         } else if (args[0].equalsIgnoreCase(STOP)) {
             final RemoteServer remoteServer = new RemoteServer();
             remoteServer.serverHasAlreadyBeenStarted = false;
@@ -136,16 +144,20 @@ public class RemoteServer {
 
     public void destroy() {
 
-        final boolean stopSent = stop();
+        try {
+            final boolean stopSent = stop();
 
-        final Process p = server.get();
-        if (p != null) {
+            final Process p = server.get();
+            if (p != null) {
 
-            if (stopSent) {
-                waitFor(p);
-            } else {
-                p.destroy();
+                if (stopSent) {
+                    waitFor(p);
+                } else {
+                    p.destroy();
+                }
             }
+        } catch (final Exception e) {
+            Logger.getLogger(RemoteServer.class.getName()).log(Level.WARNING, "Failed to destroy server", e);
         }
     }
 
@@ -360,13 +372,11 @@ public class RemoteServer {
             if (port > 0) {
                 if (debug) {
                     if (!connect(port, Integer.MAX_VALUE)) {
-                        destroy();
-                        throw new OpenEJBRuntimeException("Could not connect to server");
+                        throw new OpenEJBRuntimeException("Could not connect to server: " + this.host + ":" + port);
                     }
                 } else {
                     if (!connect(port, tries)) {
-                        destroy();
-                        throw new OpenEJBRuntimeException("Could not connect to server");
+                        throw new OpenEJBRuntimeException("Could not connect to server: " + this.host + ":" + port);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
index d28a6c8..02444f6 100644
--- a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
+++ b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
@@ -1352,7 +1352,8 @@ public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
     protected void serverCmd(final RemoteServer server, final List<String> strings) {
         try {
             server.start(strings, getCmd(), checkStarted);
-        } catch (final OpenEJBRuntimeException e) {
+        } catch (final Exception e) {
+            //TODO - Optional server.destroy()
             getLog().warn("Failed to check or track server startup on port: " + this.tomeeHttpPort);
         }
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
index 52132df..0b76bed 100644
--- a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
+++ b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/runner/ExecRunner.java
@@ -152,7 +152,14 @@ public class ExecRunner {
                 if ("run".equals(args[0])) {
                     args[0] = "start";
                 }
-                server.start(jvmArgs, args[0], true);
+
+                try {
+                    server.start(jvmArgs, args[0], true);
+                } catch (final Exception e) {
+                    server.destroy();
+                    throw e;
+                }
+
                 if (doWait) {
                     server.getServer().waitFor();
                 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/ContainersImplTomEE.java
----------------------------------------------------------------------
diff --git a/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/ContainersImplTomEE.java b/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/ContainersImplTomEE.java
index 40cf5c3..813ff75 100644
--- a/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/ContainersImplTomEE.java
+++ b/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/ContainersImplTomEE.java
@@ -1,165 +1,170 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.tck.impl;
-
-import org.apache.openejb.assembler.Deployer;
-import org.apache.openejb.assembler.classic.AppInfo;
-import org.apache.openejb.client.RemoteInitialContextFactory;
-import org.apache.openejb.config.RemoteServer;
-import org.apache.openejb.config.ValidationException;
-import org.apache.openejb.loader.Options;
-import org.apache.openejb.tck.OpenEJBTCKRuntimeException;
-import org.apache.openejb.tck.util.ServerLocal;
-import org.jboss.testharness.api.DeploymentException;
-import org.jboss.testharness.spi.Containers;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Properties;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ContainersImplTomEE extends AbstractContainers implements Containers {
-    private static int count = 0;
-    private final RemoteServer server;
-    private Deployer deployer = null;
-    private Exception exception;
-    private AppInfo appInfo;
-    private File currentFile = null;
-    private final int port = ServerLocal.getPort(8080);
-
-    private Deployer lookup() {
-        final Options options = new Options(System.getProperties());
-        final Properties props = new Properties();
-        props.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
-        props.put(Context.PROVIDER_URL, options.get(Context.PROVIDER_URL, "http://localhost:" + port + "/tomee/ejb"));
-
-        final String deployerJndi = System.getProperty("openejb.deployer.jndiname", "openejb/DeployerBusinessRemote");
-
-        try {
-            final InitialContext context = new InitialContext(props);
-            return (Deployer) context.lookup(deployerJndi);
-        } catch (final Exception e) {
-            throw new OpenEJBTCKRuntimeException(e);
-        }
-    }
-
-    public ContainersImplTomEE() {
-        System.out.println("ContainersImpl=" + ContainersImplTomEE.class.getName());
-        System.out.println("Initialized ContainersImplTomEE " + (++count) + ", wait port = " + port);
-        server = new RemoteServer();
-        server.setPortStartup(this.port);
-    }
-
-    @Override
-    public boolean deploy(final InputStream archive, final String name) throws IOException {
-        exception = null;
-        appInfo = null;
-
-        System.out.println("Deploying " + archive + " with name " + name);
-
-        currentFile = getFile(name);
-        System.out.println(currentFile);
-        writeToFile(currentFile, archive);
-        try {
-            if (deployer == null) {
-                deployer = lookup();
-            }
-            appInfo = deployer.deploy(currentFile.getAbsolutePath());
-        } catch (final Exception ex) {
-            Exception e = ex;
-            if (e.getCause() instanceof ValidationException) {
-                e = (Exception) e.getCause();
-            }
-
-            if (name.contains(".broken.")) {
-                // Tests that contain the name '.broken.' are expected to fail deployment
-                // This is how the TCK verifies the container is doing the required error checking
-                exception = (DeploymentException) new DeploymentException("deploy failed").initCause(e);
-            } else {
-                // This on the other hand is not good ....
-                System.out.println("FIX Deployment of " + name);
-                e.printStackTrace();
-                exception = e;
-            }
-
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public DeploymentException getDeploymentException() {
-        try {
-            return (DeploymentException) exception;
-        } catch (final Exception e) {
-            System.out.println("BADCAST");
-            return new DeploymentException("", exception);
-        }
-    }
-
-    @Override
-    public void undeploy(final String name) throws IOException {
-        if (appInfo == null) {
-            if (!(exception instanceof DeploymentException)) {
-                System.out.println("Nothing to undeploy" + name);
-            }
-            return;
-        }
-
-        System.out.println("Undeploying " + name);
-        try {
-            deployer.undeploy(appInfo.path);
-        } catch (final Exception e) {
-            e.printStackTrace();
-            throw new OpenEJBTCKRuntimeException(e);
-        }
-
-        final File toDelete;
-        if (currentFile != null && (toDelete = currentFile.getParentFile()).exists()) {
-            System.out.println("deleting " + toDelete.getAbsolutePath());
-            delete(toDelete);
-        }
-    }
-
-    protected File getFile(final String name) {
-        final File dir = new File(tmpDir, Math.random() + "");
-        if (!dir.exists() && !dir.mkdir()) {
-            throw new RuntimeException("Failed to create directory: " + dir);
-        }
-        dir.deleteOnExit();
-        return new File(dir, name);
-    }
-
-    @Override
-    public void setup() throws IOException {
-        System.out.println("Setup called");
-        server.start(Arrays.asList("-Dopenejb.classloader.forced-load=org.apache.openejb.tck"), "start", true);
-        System.out.println("Started");
-    }
-
-    @Override
-    public void cleanup() throws IOException {
-        System.out.println("Cleanup called");
-        server.destroy();
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.tck.impl;
+
+import org.apache.openejb.assembler.Deployer;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.client.RemoteInitialContextFactory;
+import org.apache.openejb.config.RemoteServer;
+import org.apache.openejb.config.ValidationException;
+import org.apache.openejb.loader.Options;
+import org.apache.openejb.tck.OpenEJBTCKRuntimeException;
+import org.apache.openejb.tck.util.ServerLocal;
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.testharness.spi.Containers;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Properties;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ContainersImplTomEE extends AbstractContainers implements Containers {
+    private static int count = 0;
+    private final RemoteServer server;
+    private Deployer deployer = null;
+    private Exception exception;
+    private AppInfo appInfo;
+    private File currentFile = null;
+    private final int port = ServerLocal.getPort(8080);
+
+    private Deployer lookup() {
+        final Options options = new Options(System.getProperties());
+        final Properties props = new Properties();
+        props.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
+        props.put(Context.PROVIDER_URL, options.get(Context.PROVIDER_URL, "http://localhost:" + port + "/tomee/ejb"));
+
+        final String deployerJndi = System.getProperty("openejb.deployer.jndiname", "openejb/DeployerBusinessRemote");
+
+        try {
+            final InitialContext context = new InitialContext(props);
+            return (Deployer) context.lookup(deployerJndi);
+        } catch (final Exception e) {
+            throw new OpenEJBTCKRuntimeException(e);
+        }
+    }
+
+    public ContainersImplTomEE() {
+        System.out.println("ContainersImpl=" + ContainersImplTomEE.class.getName());
+        System.out.println("Initialized ContainersImplTomEE " + (++count) + ", wait port = " + port);
+        server = new RemoteServer();
+        server.setPortStartup(this.port);
+    }
+
+    @Override
+    public boolean deploy(final InputStream archive, final String name) throws IOException {
+        exception = null;
+        appInfo = null;
+
+        System.out.println("Deploying " + archive + " with name " + name);
+
+        currentFile = getFile(name);
+        System.out.println(currentFile);
+        writeToFile(currentFile, archive);
+        try {
+            if (deployer == null) {
+                deployer = lookup();
+            }
+            appInfo = deployer.deploy(currentFile.getAbsolutePath());
+        } catch (final Exception ex) {
+            Exception e = ex;
+            if (e.getCause() instanceof ValidationException) {
+                e = (Exception) e.getCause();
+            }
+
+            if (name.contains(".broken.")) {
+                // Tests that contain the name '.broken.' are expected to fail deployment
+                // This is how the TCK verifies the container is doing the required error checking
+                exception = (DeploymentException) new DeploymentException("deploy failed").initCause(e);
+            } else {
+                // This on the other hand is not good ....
+                System.out.println("FIX Deployment of " + name);
+                e.printStackTrace();
+                exception = e;
+            }
+
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public DeploymentException getDeploymentException() {
+        try {
+            return (DeploymentException) exception;
+        } catch (final Exception e) {
+            System.out.println("BADCAST");
+            return new DeploymentException("", exception);
+        }
+    }
+
+    @Override
+    public void undeploy(final String name) throws IOException {
+        if (appInfo == null) {
+            if (!(exception instanceof DeploymentException)) {
+                System.out.println("Nothing to undeploy" + name);
+            }
+            return;
+        }
+
+        System.out.println("Undeploying " + name);
+        try {
+            deployer.undeploy(appInfo.path);
+        } catch (final Exception e) {
+            e.printStackTrace();
+            throw new OpenEJBTCKRuntimeException(e);
+        }
+
+        final File toDelete;
+        if (currentFile != null && (toDelete = currentFile.getParentFile()).exists()) {
+            System.out.println("deleting " + toDelete.getAbsolutePath());
+            delete(toDelete);
+        }
+    }
+
+    protected File getFile(final String name) {
+        final File dir = new File(tmpDir, Math.random() + "");
+        if (!dir.exists() && !dir.mkdir()) {
+            throw new RuntimeException("Failed to create directory: " + dir);
+        }
+        dir.deleteOnExit();
+        return new File(dir, name);
+    }
+
+    @Override
+    public void setup() throws IOException {
+        System.out.println("Setup called");
+        try {
+            server.start(Arrays.asList("-Dopenejb.classloader.forced-load=org.apache.openejb.tck"), "start", true);
+        } catch (final Exception e) {
+            cleanup();
+            throw e;
+        }
+        System.out.println("Started");
+    }
+
+    @Override
+    public void cleanup() throws IOException {
+        System.out.println("Cleanup called");
+        server.destroy();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
----------------------------------------------------------------------
diff --git a/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java b/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
index 090a816..98d00e6 100644
--- a/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
+++ b/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
@@ -1,136 +1,137 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.openejb.tck.impl;
-
-import org.apache.openejb.client.RemoteInitialContextFactory;
-import org.apache.openejb.config.RemoteServer;
-import org.apache.openejb.loader.Options;
-import org.apache.openejb.tck.OpenEJBTCKRuntimeException;
-import org.apache.openejb.tck.util.ServerLocal;
-import org.apache.tomee.catalina.facade.ExceptionManagerFacade;
-import org.jboss.testharness.api.DeploymentException;
-import org.jboss.testharness.spi.Containers;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * flow:
- * - copy file
- * - start the server
- * - stop the server
- * - remove the file
- */
-public class FullRestartContainer extends AbstractContainers implements Containers {
-    private static final File WEBAPP_DIR = new File(System.getProperty("openejb.home"), "webapps/");
-    private static final File APPS_DIR = new File(System.getProperty("openejb.home"), "apps/");
-
-    private RemoteServer server;
-    private Exception exception;
-    private File currentFile;
-
-    public FullRestartContainer() {
-        System.out.println("ContainersImpl=" + FullRestartContainer.class.getName());
-    }
-
-    @Override
-    public DeploymentException getDeploymentException() {
-        if (exception instanceof DeploymentException) {
-            return (DeploymentException) exception;
-        }
-        System.out.println("BADCAST");
-        return new DeploymentException("", exception);
-    }
-
-    @Override
-    public boolean deploy(final InputStream archive, final String name) throws IOException {
-        if (name.endsWith("war")) {
-            currentFile = new File(WEBAPP_DIR, name);
-        } else {
-            currentFile = new File(APPS_DIR, name);
-        }
-
-        System.out.println(currentFile);
-        writeToFile(currentFile, archive);
-
-        final int port = ServerLocal.getPort(-1);
-        if (port > 0) {
-            server = new RemoteServer(100, true);
-            server.setPortStartup(port);
-        } else {
-            throw new OpenEJBTCKRuntimeException("Please set the tomee port using the system property 'server.http.port'");
-        }
-
-        try {
-            server.start();
-        } catch (final RuntimeException e) {
-            e.printStackTrace();
-            throw e;
-        }
-
-        return (exception = lookup().exception()) == null;
-    }
-
-    @Override
-    public void undeploy(final String name) throws IOException {
-
-        if (null != server) {
-            server.destroy();
-        }
-
-        final File folder = new File(currentFile.getParentFile(), currentFile.getName().substring(0, currentFile.getName().length() - 4));
-        if (folder.exists()) {
-            delete(folder);
-        }
-        delete(currentFile);
-    }
-
-    @Override
-    public void setup() throws IOException {
-        // no-op
-    }
-
-    @Override
-    public void cleanup() throws IOException {
-        // no-op
-    }
-
-    private ExceptionManagerFacade lookup() {
-        final Options options = new Options(System.getProperties());
-        final Properties props = new Properties();
-        props.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
-        final int port = ServerLocal.getPort(-1);
-        if (port > 0) {
-            System.out.println("provider url = " + "http://localhost:" + port + "/tomee/ejb");
-            props.put(Context.PROVIDER_URL, options.get(Context.PROVIDER_URL, "http://localhost:" + port + "/tomee/ejb"));
-        } else {
-            throw new OpenEJBTCKRuntimeException("Please set the tomee port using the system property 'server.http.port'");
-        }
-
-        try {
-            final InitialContext context = new InitialContext(props);
-            return (ExceptionManagerFacade) context.lookup("openejb/ExceptionManagerFacadeBusinessRemote");
-        } catch (final Exception e) {
-            throw new OpenEJBTCKRuntimeException(e);
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openejb.tck.impl;
+
+import org.apache.openejb.client.RemoteInitialContextFactory;
+import org.apache.openejb.config.RemoteServer;
+import org.apache.openejb.loader.Options;
+import org.apache.openejb.tck.OpenEJBTCKRuntimeException;
+import org.apache.openejb.tck.util.ServerLocal;
+import org.apache.tomee.catalina.facade.ExceptionManagerFacade;
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.testharness.spi.Containers;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * flow:
+ * - copy file
+ * - start the server
+ * - stop the server
+ * - remove the file
+ */
+public class FullRestartContainer extends AbstractContainers implements Containers {
+    private static final File WEBAPP_DIR = new File(System.getProperty("openejb.home"), "webapps/");
+    private static final File APPS_DIR = new File(System.getProperty("openejb.home"), "apps/");
+
+    private RemoteServer server;
+    private Exception exception;
+    private File currentFile;
+
+    public FullRestartContainer() {
+        System.out.println("ContainersImpl=" + FullRestartContainer.class.getName());
+    }
+
+    @Override
+    public DeploymentException getDeploymentException() {
+        if (exception instanceof DeploymentException) {
+            return (DeploymentException) exception;
+        }
+        System.out.println("BADCAST");
+        return new DeploymentException("", exception);
+    }
+
+    @Override
+    public boolean deploy(final InputStream archive, final String name) throws IOException {
+        if (name.endsWith("war")) {
+            currentFile = new File(WEBAPP_DIR, name);
+        } else {
+            currentFile = new File(APPS_DIR, name);
+        }
+
+        System.out.println(currentFile);
+        writeToFile(currentFile, archive);
+
+        final int port = ServerLocal.getPort(-1);
+        if (port > 0) {
+            server = new RemoteServer(100, true);
+            server.setPortStartup(port);
+        } else {
+            throw new OpenEJBTCKRuntimeException("Please set the tomee port using the system property 'server.http.port'");
+        }
+
+        try {
+            server.start();
+        } catch (final Exception e) {
+            server.destroy();
+            e.printStackTrace();
+            throw e;
+        }
+
+        return (exception = lookup().exception()) == null;
+    }
+
+    @Override
+    public void undeploy(final String name) throws IOException {
+
+        if (null != server) {
+            server.destroy();
+        }
+
+        final File folder = new File(currentFile.getParentFile(), currentFile.getName().substring(0, currentFile.getName().length() - 4));
+        if (folder.exists()) {
+            delete(folder);
+        }
+        delete(currentFile);
+    }
+
+    @Override
+    public void setup() throws IOException {
+        // no-op
+    }
+
+    @Override
+    public void cleanup() throws IOException {
+        // no-op
+    }
+
+    private ExceptionManagerFacade lookup() {
+        final Options options = new Options(System.getProperties());
+        final Properties props = new Properties();
+        props.put(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
+        final int port = ServerLocal.getPort(-1);
+        if (port > 0) {
+            System.out.println("provider url = " + "http://localhost:" + port + "/tomee/ejb");
+            props.put(Context.PROVIDER_URL, options.get(Context.PROVIDER_URL, "http://localhost:" + port + "/tomee/ejb"));
+        } else {
+            throw new OpenEJBTCKRuntimeException("Please set the tomee port using the system property 'server.http.port'");
+        }
+
+        try {
+            final InitialContext context = new InitialContext(props);
+            return (ExceptionManagerFacade) context.lookup("openejb/ExceptionManagerFacadeBusinessRemote");
+        } catch (final Exception e) {
+            throw new OpenEJBTCKRuntimeException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/2cef2ddb/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java b/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
index 189bc12..bc3f961 100644
--- a/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
+++ b/tomee/apache-tomee/src/main/java/org/apache/tomee/RemoteTomEEEJBContainer.java
@@ -1,162 +1,169 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.tomee;
-
-import org.apache.geronimo.osgi.locator.ProviderLocator;
-import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.assembler.Deployer;
-import org.apache.openejb.assembler.DeployerEjb;
-import org.apache.openejb.client.RemoteInitialContextFactory;
-import org.apache.openejb.config.RemoteServer;
-import org.apache.openejb.loader.IO;
-import org.apache.tomee.util.QuickServerXmlParser;
-
-import javax.ejb.EJBException;
-import javax.ejb.embeddable.EJBContainer;
-import javax.ejb.spi.EJBContainerProvider;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.validation.ValidationException;
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-public class RemoteTomEEEJBContainer extends EJBContainer {
-    private static RemoteTomEEEJBContainer instance;
-    private RemoteServer container;
-    private InitialContext context;
-
-    @Override
-    public void close() {
-        instance.container.destroy();
-        instance.container = null;
-    }
-
-    @Override
-    public Context getContext() {
-        return context;
-    }
-
-    public static class Provider implements EJBContainerProvider {
-        private static final List<String> CONTAINER_NAMES = Arrays.asList(RemoteTomEEEJBContainer.class.getName(), "tomee-remote", "remote-tomee");
-
-        @Override
-        public EJBContainer createEJBContainer(final Map<?, ?> properties) {
-            final Object provider = properties.get(EJBContainer.PROVIDER);
-            int ejbContainerProviders = 1;
-            try {
-                ejbContainerProviders = ProviderLocator.getServices(EJBContainerProvider.class.getName(), EJBContainer.class, Thread.currentThread().getContextClassLoader()).size();
-            } catch (final Exception e) {
-                // no-op
-            }
-
-            if ((provider == null && ejbContainerProviders > 1)
-                || (!RemoteTomEEEJBContainer.class.equals(provider)
-                && !CONTAINER_NAMES.contains(String.valueOf(provider)))) {
-                return null;
-            }
-
-            if (instance != null) {
-                return instance;
-            }
-
-            final Object modules = properties.get(EJBContainer.MODULES);
-
-            System.getProperties().putAll(properties);
-            final File home = new File(System.getProperty("openejb.home", "doesn't exist"));
-            if (!home.exists()) {
-                throw new IllegalArgumentException("You need to set openejb.home");
-            }
-
-            final QuickServerXmlParser parser = QuickServerXmlParser.parse(new File(home, "conf/server.xml"));
-            final String remoteEjb = System.getProperty(Context.PROVIDER_URL, "http://" + parser.host() + ":" + parser.http() + "/tomee/ejb");
-            System.setProperty(RemoteServer.SERVER_SHUTDOWN_PORT, parser.stop());
-
-            try {
-                instance = new RemoteTomEEEJBContainer();
-                instance.container = new RemoteServer();
-                instance.container.setPortStartup(Integer.parseInt(parser.http()));
-                instance.container.start();
-                instance.context = new InitialContext(new Properties() {{
-                    setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
-                    setProperty(Context.PROVIDER_URL, remoteEjb);
-                }});
-
-                Deployer deployer = null;
-                for (int i = 0; i < (properties.containsKey("retries") ? Integer.parseInt(String.class.cast(properties.get("retries"))) : 20); i++) {
-                    deployer = Deployer.class.cast(instance.context.lookup("openejb/DeployerBusinessRemote"));
-                    if (deployer != null) {
-                        break;
-                    }
-                }
-                if (deployer == null) {
-                    throw new TomEERemoteEJBContainerException("Can't lookup deployer, eother increse retries or setup it correctly", new IllegalStateException());
-                }
-
-                if (modules instanceof File) {
-                    final File file = File.class.cast(modules);
-                    deployFile(deployer, file);
-                } else if (modules instanceof String) {
-                    final String path = String.class.cast(modules);
-                    final File file = new File(path);
-                    deployFile(deployer, file);
-                } else if (modules instanceof String[]) {
-                    for (final String path : (String[]) modules) {
-                        deployFile(deployer, new File(path));
-                    }
-                } else if (modules instanceof File[]) {
-                    for (final File file : (File[]) modules) {
-                        deployFile(deployer, file);
-                    }
-                } // else suppose already deployed
-
-                return instance;
-            } catch (final OpenEJBException | MalformedURLException e) {
-                throw new EJBException(e);
-            } catch (final ValidationException ve) {
-                throw ve;
-            } catch (final Exception e) {
-                if (e instanceof EJBException) {
-                    throw (EJBException) e;
-                }
-                throw new TomEERemoteEJBContainerException("initialization exception", e);
-            }
-        }
-    }
-
-    private static void deployFile(final Deployer deployer, final File file) throws IOException, OpenEJBException {
-        if ("true".equalsIgnoreCase(System.getProperty(DeployerEjb.OPENEJB_USE_BINARIES, "false"))) {
-            final Properties props = new Properties();
-            final byte[] slurpBinaries = IO.slurp(file).getBytes();
-            props.put(DeployerEjb.OPENEJB_VALUE_BINARIES, slurpBinaries);
-            props.put(DeployerEjb.OPENEJB_PATH_BINARIES, file.getName());
-            deployer.deploy(file.getAbsolutePath(), props);
-        } else {
-            deployer.deploy(file.getAbsolutePath());
-        }
-    }
-
-    protected static class TomEERemoteEJBContainerException extends RuntimeException {
-        protected TomEERemoteEJBContainerException(final String s, final Exception e) {
-            super(s, e);
-        }
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomee;
+
+import org.apache.geronimo.osgi.locator.ProviderLocator;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.assembler.Deployer;
+import org.apache.openejb.assembler.DeployerEjb;
+import org.apache.openejb.client.RemoteInitialContextFactory;
+import org.apache.openejb.config.RemoteServer;
+import org.apache.openejb.loader.IO;
+import org.apache.tomee.util.QuickServerXmlParser;
+
+import javax.ejb.EJBException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.ejb.spi.EJBContainerProvider;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.validation.ValidationException;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public class RemoteTomEEEJBContainer extends EJBContainer {
+    private static RemoteTomEEEJBContainer instance;
+    private RemoteServer container;
+    private InitialContext context;
+
+    @Override
+    public void close() {
+        instance.container.destroy();
+        instance.container = null;
+    }
+
+    @Override
+    public Context getContext() {
+        return context;
+    }
+
+    public static class Provider implements EJBContainerProvider {
+        private static final List<String> CONTAINER_NAMES = Arrays.asList(RemoteTomEEEJBContainer.class.getName(), "tomee-remote", "remote-tomee");
+
+        @Override
+        public EJBContainer createEJBContainer(final Map<?, ?> properties) {
+            final Object provider = properties.get(EJBContainer.PROVIDER);
+            int ejbContainerProviders = 1;
+            try {
+                ejbContainerProviders = ProviderLocator.getServices(EJBContainerProvider.class.getName(), EJBContainer.class, Thread.currentThread().getContextClassLoader()).size();
+            } catch (final Exception e) {
+                // no-op
+            }
+
+            if ((provider == null && ejbContainerProviders > 1)
+                || (!RemoteTomEEEJBContainer.class.equals(provider)
+                && !CONTAINER_NAMES.contains(String.valueOf(provider)))) {
+                return null;
+            }
+
+            if (instance != null) {
+                return instance;
+            }
+
+            final Object modules = properties.get(EJBContainer.MODULES);
+
+            System.getProperties().putAll(properties);
+            final File home = new File(System.getProperty("openejb.home", "doesn't exist"));
+            if (!home.exists()) {
+                throw new IllegalArgumentException("You need to set openejb.home");
+            }
+
+            final QuickServerXmlParser parser = QuickServerXmlParser.parse(new File(home, "conf/server.xml"));
+            final String remoteEjb = System.getProperty(Context.PROVIDER_URL, "http://" + parser.host() + ":" + parser.http() + "/tomee/ejb");
+            System.setProperty(RemoteServer.SERVER_SHUTDOWN_PORT, parser.stop());
+
+            try {
+                instance = new RemoteTomEEEJBContainer();
+                instance.container = new RemoteServer();
+                instance.container.setPortStartup(Integer.parseInt(parser.http()));
+
+                try {
+                    instance.container.start();
+                } catch (final Exception e) {
+                    instance.container.destroy();
+                    throw e;
+                }
+
+                instance.context = new InitialContext(new Properties() {{
+                    setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
+                    setProperty(Context.PROVIDER_URL, remoteEjb);
+                }});
+
+                Deployer deployer = null;
+                for (int i = 0; i < (properties.containsKey("retries") ? Integer.parseInt(String.class.cast(properties.get("retries"))) : 20); i++) {
+                    deployer = Deployer.class.cast(instance.context.lookup("openejb/DeployerBusinessRemote"));
+                    if (deployer != null) {
+                        break;
+                    }
+                }
+                if (deployer == null) {
+                    throw new TomEERemoteEJBContainerException("Can't lookup deployer, eother increse retries or setup it correctly", new IllegalStateException());
+                }
+
+                if (modules instanceof File) {
+                    final File file = File.class.cast(modules);
+                    deployFile(deployer, file);
+                } else if (modules instanceof String) {
+                    final String path = String.class.cast(modules);
+                    final File file = new File(path);
+                    deployFile(deployer, file);
+                } else if (modules instanceof String[]) {
+                    for (final String path : (String[]) modules) {
+                        deployFile(deployer, new File(path));
+                    }
+                } else if (modules instanceof File[]) {
+                    for (final File file : (File[]) modules) {
+                        deployFile(deployer, file);
+                    }
+                } // else suppose already deployed
+
+                return instance;
+            } catch (final OpenEJBException | MalformedURLException e) {
+                throw new EJBException(e);
+            } catch (final ValidationException ve) {
+                throw ve;
+            } catch (final Exception e) {
+                if (e instanceof EJBException) {
+                    throw (EJBException) e;
+                }
+                throw new TomEERemoteEJBContainerException("initialization exception", e);
+            }
+        }
+    }
+
+    private static void deployFile(final Deployer deployer, final File file) throws IOException, OpenEJBException {
+        if ("true".equalsIgnoreCase(System.getProperty(DeployerEjb.OPENEJB_USE_BINARIES, "false"))) {
+            final Properties props = new Properties();
+            final byte[] slurpBinaries = IO.slurp(file).getBytes();
+            props.put(DeployerEjb.OPENEJB_VALUE_BINARIES, slurpBinaries);
+            props.put(DeployerEjb.OPENEJB_PATH_BINARIES, file.getName());
+            deployer.deploy(file.getAbsolutePath(), props);
+        } else {
+            deployer.deploy(file.getAbsolutePath());
+        }
+    }
+
+    protected static class TomEERemoteEJBContainerException extends RuntimeException {
+        protected TomEERemoteEJBContainerException(final String s, final Exception e) {
+            super(s, e);
+        }
+    }
+}