tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1231771 - in /openejb/trunk/openejb: container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/config/ tck/tck-common/src/main/java/org/apache/openejb/tck/impl/ tomee...
Date Sun, 15 Jan 2012 22:06:42 GMT
Author: rmannibucau
Date: Sun Jan 15 22:06:41 2012
New Revision: 1231771

URL: http://svn.apache.org/viewvc?rev=1231771&view=rev
Log:
saving exception thrown by apps/ applications to be able to retreive the exception later

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentExceptionManager.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
    openejb/trunk/openejb/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
    openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
    openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/deployer/WebappDeployer.java
    openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/facade/ExceptionManagerFacadeBean.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
Sun Jan 15 22:06:41 2012
@@ -412,7 +412,7 @@ public class Assembler extends Assembler
 
                 final DeploymentExceptionManager exceptionManager = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
                 if (exceptionManager != null && e instanceof Exception) {
-                    exceptionManager.saveDelpoymentException(appInfo, (Exception) e);
+                    exceptionManager.saveDeploymentException(appInfo, (Exception) e);
                 }
             }
         }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentExceptionManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentExceptionManager.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentExceptionManager.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/DeploymentExceptionManager.java
Sun Jan 15 22:06:41 2012
@@ -17,8 +17,6 @@
 
 package org.apache.openejb.assembler.classic;
 
-import org.apache.openejb.assembler.classic.AppInfo;
-
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -36,27 +34,33 @@ public class DeploymentExceptionManager 
             return size() > MAX_SIZE;
         }
     };
+    private Exception lastException = null;
 
-    public synchronized boolean hasDelpoymentFailed(AppInfo appInfo) {
-        return deploymentException.containsKey(appInfo);
+    public synchronized boolean hasDeploymentFailed() {
+        return lastException != null;
     }
 
-    public synchronized Exception getDelpoymentException(AppInfo appInfo) {
+    public synchronized Exception getDeploymentException(final AppInfo appInfo) {
         return deploymentException.get(appInfo);
     }
 
-    public synchronized Exception saveDelpoymentException(AppInfo appInfo, Exception exception)
{
+    public synchronized Exception saveDeploymentException(final AppInfo appInfo, final Exception
exception) {
+        lastException = exception;
         return deploymentException.put(appInfo, exception);
     }
 
-    public synchronized void clearDelpoymentException(AppInfo info) {
-        deploymentException.remove(info);
+    public synchronized void clearLastException(final AppInfo info) {
+        if (info != null && deploymentException.get(info) == lastException) {
+            deploymentException.remove(info);
+        }
+        lastException = null;
     }
 
-    public Exception getFirstException() {
-        if (deploymentException.isEmpty()) {
-            return null;
-        }
-        return deploymentException.values().iterator().next();
+    public Exception getLastException() {
+        return lastException;
+    }
+
+    public void pushDelpoymentException(final Exception exception) {
+        lastException = exception;
     }
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Sun Jan 15 22:06:41 2012
@@ -27,6 +27,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.assembler.classic.ConnectorInfo;
 import org.apache.openejb.assembler.classic.ContainerInfo;
 import org.apache.openejb.assembler.classic.ContainerSystemInfo;
+import org.apache.openejb.assembler.classic.DeploymentExceptionManager;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.assembler.classic.FacilitiesInfo;
 import org.apache.openejb.assembler.classic.HandlerChainInfo;
@@ -360,6 +361,7 @@ public class ConfigurationFactory implem
         List<String> declaredApps = getDeclaredApps();
 
         for (String pathname : declaredApps) {
+            AppInfo appInfo = null;
             try {
                 try {
                     final File jarFile;
@@ -369,13 +371,19 @@ public class ConfigurationFactory implem
                         jarFile = new File(pathname);
                     }
 
-                    AppInfo appInfo = configureApplication(jarFile);
+                    appInfo = configureApplication(jarFile);
 
                     sys.containerSystem.applications.add(appInfo);
                 } catch (URISyntaxException e) {
                     logger.error("Invalid declaredApp URI '" + pathname + "'", e);
                 }
             } catch (OpenEJBException alreadyHandled) {
+                final DeploymentExceptionManager exceptionManager = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
+                if (appInfo != null) {
+                    exceptionManager.saveDeploymentException(appInfo, alreadyHandled);
+                } else {
+                    exceptionManager.pushDelpoymentException(alreadyHandled);
+                }
             }
         }
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
Sun Jan 15 22:06:41 2012
@@ -178,6 +178,7 @@ public class RemoteServer {
                     File conf = new File(home, "conf");
                     File loggingProperties = new File(conf, "logging.properties");
 
+
                     File endorsed = new File(home, "endorsed");
                     File temp = new File(home, "temp");
 

Modified: openejb/trunk/openejb/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
(original)
+++ openejb/trunk/openejb/tck/tck-common/src/main/java/org/apache/openejb/tck/impl/FullRestartContainer.java
Sun Jan 15 22:06:41 2012
@@ -27,8 +27,10 @@ import org.jboss.testharness.spi.Contain
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
 import java.util.Properties;
 
 /**
@@ -70,6 +72,8 @@ public class FullRestartContainer extend
         System.out.println(currentFile);
         writeToFile(currentFile, archive);
 
+        addLogFiles();
+
         server = new RemoteServer(100, true);
         try {
             server.start();
@@ -81,6 +85,34 @@ public class FullRestartContainer extend
         return (exception = lookup().exception()) == null;
     }
 
+    private static void addLogFiles() throws IOException {
+        final File tomee = new File(System.getProperty("openejb.home"));
+        if (tomee.exists()) {
+            final File log4j = new File(tomee, "lib/log4j.xml");
+            final FileWriter log4jWriter = new FileWriter(log4j);
+            log4jWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                    "<!DOCTYPE log4j:configuration SYSTEM \"log4j.dtd\">\n" +
+                    "<log4j:configuration xmlns:log4j=\"http://jakarta.apache.org/log4j/\"
debug=\"false\">\n" +
+                    "  <appender name=\"stdout\" class=\"org.apache.log4j.ConsoleAppender\">\n"
+
+                    "    <param name=\"Target\" value=\"System.out\" />\n" +
+                    "    <layout class=\"org.apache.log4j.SimpleLayout\" />\n" +
+                    "  </appender>\n" +
+                    "  <root>\n" +
+                    "    <priority value=\"INFO\"/>\n" +
+                    "    <appender-ref ref=\"stdout\"/>\n" +
+                    "  </root>\n" +
+                    "</log4j:configuration>\n");
+            log4jWriter.close();
+
+            final File systemProperties = new File(tomee, "conf/system.properties");
+            final FileWriter systemPropertiesWriter = new FileWriter(systemProperties);
+            systemPropertiesWriter.write("openejb.logger.external=true");
+            systemPropertiesWriter.close();
+        } else {
+            System.out.println("tomee folder doesn't exist");
+        }
+    }
+
     @Override
     public void undeploy(String name) throws IOException {
         server.destroy();

Modified: openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
(original)
+++ openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
Sun Jan 15 22:06:41 2012
@@ -598,7 +598,7 @@ public class TomcatWebAppBuilder impleme
                     if (System.getProperty(TOMEE_EAT_EXCEPTION_PROP) == null) {
                         final TomEERuntimeException tre = new TomEERuntimeException(e);
                         DeploymentExceptionManager dem = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
-                        dem.saveDelpoymentException(contextInfo.appInfo, tre);
+                        dem.saveDeploymentException(contextInfo.appInfo, tre);
                         throw tre;
                     }
                     return;

Modified: openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/deployer/WebappDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/deployer/WebappDeployer.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/deployer/WebappDeployer.java
(original)
+++ openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/deployer/WebappDeployer.java
Sun Jan 15 22:06:41 2012
@@ -118,10 +118,10 @@ public class WebappDeployer implements D
             }
 
             final DeploymentExceptionManager dem = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
-            if (dem.hasDelpoymentFailed(info)) {
-                Exception tre = dem.getDelpoymentException(info);
-                // we don't need this exceptino anymore
-                dem.clearDelpoymentException(info);
+            if (dem.hasDeploymentFailed()) {
+                final Exception tre = dem.getLastException();
+                // we don't need this exception anymore
+                dem.clearLastException(info);
                 throw tre;
             }
 

Modified: openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/facade/ExceptionManagerFacadeBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/facade/ExceptionManagerFacadeBean.java?rev=1231771&r1=1231770&r2=1231771&view=diff
==============================================================================
--- openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/facade/ExceptionManagerFacadeBean.java
(original)
+++ openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/facade/ExceptionManagerFacadeBean.java
Sun Jan 15 22:06:41 2012
@@ -28,6 +28,6 @@ import javax.ejb.TransactionManagementTy
 @TransactionManagement(TransactionManagementType.BEAN)
 public class ExceptionManagerFacadeBean implements ExceptionManagerFacade {
     public Exception exception() {
-        return SystemInstance.get().getComponent(DeploymentExceptionManager.class).getFirstException();
+        return SystemInstance.get().getComponent(DeploymentExceptionManager.class).getLastException();
     }
 }



Mime
View raw message