User: fleury
Date: 00/09/29 14:25:17
Modified: src/main/org/jboss/ejb ContainerFactory.java
EntityContainer.java StatefulSessionContainer.java
StatelessSessionContainer.java
Log:
Updated exception handling in entire server
Log is now inherited in child threads (e.g. useful for Tomcat which spawns threads)
Revision Changes Path
1.44 +3 -3 jboss/src/main/org/jboss/ejb/ContainerFactory.java
Index: ContainerFactory.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/ContainerFactory.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- ContainerFactory.java 2000/09/28 01:16:58 1.43
+++ ContainerFactory.java 2000/09/29 21:25:16 1.44
@@ -76,7 +76,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
*
-* @version $Revision: 1.43 $
+* @version $Revision: 1.44 $
*/
public class ContainerFactory
extends org.jboss.util.ServiceMBeanSupport
@@ -647,7 +647,7 @@
// Register deployment. Use the original name in the hashtable
deployments.put(origUrl, app);
}
- catch (Throwable e)
+ catch (Exception e)
{
if (e instanceof NullPointerException) {
// Avoids useless 'null' messages on a server trace.
@@ -662,7 +662,7 @@
app.stop();
app.destroy();
- throw new DeploymentException("Could not deploy "+url.toString());
+ throw new DeploymentException("Could not deploy "+url.toString(), e);
} finally
{
Log.unsetLog();
1.28 +49 -34 jboss/src/main/org/jboss/ejb/EntityContainer.java
Index: EntityContainer.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/EntityContainer.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- EntityContainer.java 2000/09/28 01:16:59 1.27
+++ EntityContainer.java 2000/09/29 21:25:16 1.28
@@ -20,6 +20,7 @@
import javax.ejb.EJBObject;
import javax.ejb.EJBHome;
import javax.ejb.EJBMetaData;
+import javax.ejb.EJBException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
@@ -35,7 +36,7 @@
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
-* @version $Revision: 1.27 $
+* @version $Revision: 1.28 $
*/
public class EntityContainer
extends Container
@@ -305,24 +306,14 @@
public Object invokeHome(MethodInvocation mi)
throws Exception
{
-
- Logger.debug("invokeHome");
- try { return getInterceptor().invokeHome(mi); }
- catch (Exception e) {e.printStackTrace(); throw e;}
-
- // return getInterceptor().invokeHome(mi);
-
+ return getInterceptor().invokeHome(mi);
}
public Object invoke(MethodInvocation mi)
throws Exception
{
- try { return getInterceptor().invoke(mi); }
- catch (Exception e) {e.printStackTrace();throw e;}
-
-
- // Invoke through interceptors
- // return getInterceptor().invoke(mi);
+ // Invoke through interceptors
+ return getInterceptor().invoke(mi);
}
// EJBObject implementation --------------------------------------
@@ -592,13 +583,21 @@
try
{
return m.invoke(EntityContainer.this, new Object[] { mi });
- } catch (InvocationTargetException e)
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
{
Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
+ if (ex instanceof EJBException)
+ throw (Exception)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform runtime
exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
else
- throw (Error)ex;
+ throw (Error)ex;
}
}
@@ -615,14 +614,22 @@
try
{
return m.invoke(EntityContainer.this, new Object[] { mi });
- } catch (InvocationTargetException e)
- {
- Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
- else
- throw (Error)ex;
- }
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
+ {
+ Throwable ex = e.getTargetException();
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform
runtime exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
+ }
} else
{
//wire the transaction on the context, this is how the instance
remember the tx
@@ -632,14 +639,22 @@
try
{
return m.invoke(mi.getEnterpriseContext().getInstance(),
mi.getArguments());
- } catch (InvocationTargetException e)
- {
- Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
- else
- throw (Error)ex;
- }
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
+ {
+ Throwable ex = e.getTargetException();
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform
runtime exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
+ }
}
}
}
1.18 +52 -30 jboss/src/main/org/jboss/ejb/StatefulSessionContainer.java
Index: StatefulSessionContainer.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/StatefulSessionContainer.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- StatefulSessionContainer.java 2000/09/28 01:16:59 1.17
+++ StatefulSessionContainer.java 2000/09/29 21:25:16 1.18
@@ -23,6 +23,7 @@
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
+import javax.ejb.EJBException;
import org.jboss.logging.Logger;
@@ -31,7 +32,7 @@
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.17 $
+ * @version $Revision: 1.18 $
*/
public class StatefulSessionContainer
extends Container
@@ -502,45 +503,58 @@
Method m = (Method)homeMapping.get(mi.getMethod());
// Invoke and handle exceptions
- Logger.debug("SSC:invokeHome:mi is "+mi.getMethod().getName()+" map is
"+m.getName());
- try
- {
- return m.invoke(StatefulSessionContainer.this, new Object[] { mi });
- } catch (InvocationTargetException e)
- {
- Logger.debug(e.getMessage());
- Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
- else
- throw (Error)ex;
- }
+ try
+ {
+ return m.invoke(StatefulSessionContainer.this, new Object[] { mi });
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
+ {
+ Throwable ex = e.getTargetException();
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform runtime
exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
+ }
}
public Object invoke(MethodInvocation mi)
throws Exception
{
+ //wire the transaction on the context, this is how the instance remember
the tx
+ if (mi.getEnterpriseContext().getTransaction() == null)
mi.getEnterpriseContext().setTransaction(mi.getTransaction());
+
// Get method
Method m = (Method)beanMapping.get(mi.getMethod());
- Logger.debug("SSC:invoke:mi is "+mi.getMethod().getName()+" map is
"+m.getName());
// Select instance to invoke (container or bean)
if (m.getDeclaringClass().equals(StatefulSessionContainer.this.getClass()))
{
- //wire the transaction on the context, this is how the
instance remember the tx
- if (mi.getEnterpriseContext().getTransaction() == null)
mi.getEnterpriseContext().setTransaction(mi.getTransaction());
-
// Invoke and handle exceptions
try
{
return m.invoke(StatefulSessionContainer.this, new Object[] { mi });
- } catch (InvocationTargetException e)
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
{
- Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
- else
- throw (Error)ex;
+ Throwable ex = e.getTargetException();
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform runtime
exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
}
} else
{
@@ -548,13 +562,21 @@
try
{
return m.invoke(mi.getEnterpriseContext().getInstance(),
mi.getArguments());
- } catch (InvocationTargetException e)
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
{
- Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
- else
- throw (Error)ex;
+ Throwable ex = e.getTargetException();
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform runtime
exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
}
}
}
1.13 +47 -19 jboss/src/main/org/jboss/ejb/StatelessSessionContainer.java
Index: StatelessSessionContainer.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/StatelessSessionContainer.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- StatelessSessionContainer.java 2000/09/28 01:16:59 1.12
+++ StatelessSessionContainer.java 2000/09/29 21:25:16 1.13
@@ -19,6 +19,7 @@
import javax.ejb.EJBMetaData;
import javax.ejb.CreateException;
import javax.ejb.RemoveException;
+import javax.ejb.EJBException;
import org.jboss.logging.Logger;
@@ -28,7 +29,7 @@
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.12 $
+* @version $Revision: 1.13 $
*/
public class StatelessSessionContainer
extends Container
@@ -408,19 +409,30 @@
try
{
return m.invoke(StatelessSessionContainer.this, mi.getArguments());
- } catch (InvocationTargetException e)
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
{
Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
- else
- throw (Error)ex;
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform runtime
exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
}
}
public Object invoke(MethodInvocation mi)
throws Exception
{
+ //wire the transaction on the context, this is how the instance
remember the tx
+ if (mi.getEnterpriseContext().getTransaction() == null)
mi.getEnterpriseContext().setTransaction(mi.getTransaction());
+
// Get method and instance to invoke upon
Method m = (Method)beanMapping.get(mi.getMethod());
@@ -430,28 +442,44 @@
try
{
return m.invoke(StatelessSessionContainer.this, new Object[] {
mi });
- } catch (InvocationTargetException e)
- {
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
+ {
Throwable ex = e.getTargetException();
-
- if (ex instanceof Exception) throw (Exception)ex;
- else throw (Error)ex;
- }
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform runtime
exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
+ }
} else // we have a method that needs to be done by a bean instance
{
- // MF FIXME we don't need to wire the Transaction to the
context?
-
// Invoke and handle exceptions
try
{
return m.invoke(mi.getEnterpriseContext().getInstance(),
mi.getArguments());
- } catch (InvocationTargetException e)
+ } catch (IllegalAccessException e)
+ {
+ // Throw this as a bean exception...(?)
+ throw new EJBException(e);
+ } catch (InvocationTargetException e)
{
Throwable ex = e.getTargetException();
-
- if (ex instanceof Exception) throw (Exception)ex;
- else throw (Error)ex;
- }
+ if (ex instanceof EJBException)
+ throw (EJBException)ex;
+ else if (ex instanceof RuntimeException)
+ throw new EJBException((Exception)ex); // Transform runtime
exception into what a bean *should* have thrown
+ else if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
+ }
}
}
}