[jboss-cvs] JBossAS SVN: r88060 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 30 07:27:03 EDT 2009


Author: jaikiran
Date: 2009-04-30 07:27:03 -0400 (Thu, 30 Apr 2009)
New Revision: 88060

Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
Log:
EJBTHREE-1815 Better error messages on unexpected deployment errors.

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java	2009-04-30 11:22:19 UTC (rev 88059)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java	2009-04-30 11:27:03 UTC (rev 88060)
@@ -441,7 +441,7 @@
       }
       catch (Exception e)
       {
-         log.debug("error trying to stop ejb deployment", e);
+         log.debug("error trying to stop ejb deployment: " + objectName, e);
       }
    }
 
@@ -515,37 +515,75 @@
 
    public void start() throws Exception
    {
-      try
+     
+      if (reinitialize)
+         reinitialize();
+      
+      for (Object o : ejbContainers.values())
       {
-         if (reinitialize)
-            reinitialize();
-         
-         for (Object o : ejbContainers.values())
+         Container con = (Container) o;
+         try 
          {
-            Container con = (Container) o;
             processEJBContainerMetadata(con);
          }
-
-         for (Object o : ejbContainers.values())
+         catch (Exception e)
          {
-            Container con = (Container) o;
-            registerEJBContainer(con);
+            String message = "Exception while processing container metadata for EJB: " + con.getEjbName() + " in unit: " + this.getDeploymentUnit().getShortName();
+            // just log the message, no need to dump the stacktrace since we are finally going to
+            // throw back the exception
+            log.error(message);
+            // stop/destroy the container(s) in this deployment
+            try 
+            {
+               stop();
+               destroy();
+            }
+            catch (Exception ignoredException)  
+            {
+               // we catch this exception during stop/destroy to ensure that this 
+               // exception is NOT propagated up, instead of the original exception
+               // that forced this stop/destroy
+            }
+            // now wrap the original exception with a meaningful message and
+            // throw back the exception.
+            throw new Exception(message, e);
          }
+      }
 
-         //putJaccInService(pc, unit);
-      }
-      catch (Exception ex)
+      for (Object o : ejbContainers.values())
       {
-         try
+         Container con = (Container) o;
+         try 
          {
-            stop();
-            destroy();
+            registerEJBContainer(con);
          }
-         catch (Exception ignored)
+         catch (Exception e)
          {
+            String message = "Exception while registering EJB container for EJB: " + con.getEjbName() + " in unit: " + this.getDeploymentUnit().getShortName();
+            // just log the message, no need to dump the stacktrace since we are finally going to
+            // throw back the exception
+            log.error(message);
+            // stop/destroy the container(s) in this deployment
+            try 
+            {
+               stop();
+               destroy();
+            }
+            catch (Exception ignoredException)  
+            {
+               // we catch this exception during stop/destroy to ensure that this 
+               // exception is NOT propagated up, instead of the original exception
+               // that forced this stop/destroy
+            }
+            // now wrap the original exception with a meaningful message and
+            // throw back the exception.
+            throw new Exception(message, e);
+
          }
-         throw ex;
       }
+
+      //putJaccInService(pc, unit);
+      
    }
    
    public void stop() //throws Exception
@@ -559,7 +597,7 @@
          }
          catch (Exception e)
          {
-            log.debug("error trying to stop ejb container", e);
+            log.debug("error trying to stop ejb container: " + on, e);
          }
       }
       
@@ -654,9 +692,18 @@
             // EJBContainer has finished with all metadata initialization from XML files and such.
             // this is really a hook to do some processing after XML has been set up and before
             // and processing of dependencies and such.
-            ((EJBContainer) con).instantiated();
-            this.ejbContainers.put(con.getObjectName(), con);
-            Ejb3Registry.register(con);
+            try 
+            {
+               ((EJBContainer) con).instantiated();
+               this.ejbContainers.put(con.getObjectName(), con);
+               Ejb3Registry.register(con);
+               
+            } catch (Throwable t)
+            {
+               throw new DeploymentException(
+                     "Error creating ejb container " + con.getEjbName() + ": " + t.getMessage(), t);
+
+            }
          }
       }
    }




More information about the jboss-cvs-commits mailing list