Author: alessio.soldano(a)jboss.com
Date: 2008-07-09 07:11:34 -0400 (Wed, 09 Jul 2008)
New Revision: 7805
Modified:
stack/metro/trunk/modules/server/pom.xml
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java
Log:
[JBWS-2087] Fixing invocation exception handling for EJB3 endpoints
Modified: stack/metro/trunk/modules/server/pom.xml
===================================================================
--- stack/metro/trunk/modules/server/pom.xml 2008-07-09 11:09:08 UTC (rev 7804)
+++ stack/metro/trunk/modules/server/pom.xml 2008-07-09 11:11:34 UTC (rev 7805)
@@ -97,6 +97,11 @@
<artifactId>jboss-common</artifactId>
</dependency>
<dependency>
+ <groupId>javax.ejb</groupId>
+ <artifactId>ejb-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
Modified:
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java
===================================================================
---
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java 2008-07-09
11:09:08 UTC (rev 7804)
+++
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/InvokerEJB3.java 2008-07-09
11:11:34 UTC (rev 7805)
@@ -26,7 +26,9 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import javax.ejb.EJBException;
import javax.xml.ws.Provider;
+import javax.xml.ws.WebFault;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
@@ -105,12 +107,24 @@
private void handleException(Exception ex)
throws InvocationTargetException, IllegalAccessException
{
+ //Unwrap EJBException
+ if (ex instanceof EJBException)
+ ex = ((EJBException)ex).getCausedByException();
+
if (ex instanceof InvocationTargetException)
throw (InvocationTargetException)ex;
if (ex instanceof IllegalAccessException)
throw (IllegalAccessException)ex;
-
+
+ //check if this is a declared fault; Metro expects an InvocationTargetException
+ //for declared faults also when calling an EJB3 endpoint
+ if (ex.getClass().isAnnotationPresent(WebFault.class))
+ throw new InvocationTargetException(ex);
+
+ if (ex instanceof WebServiceException)
+ throw (WebServiceException)ex;
+
throw new WebServiceException(ex);
}
}
\ No newline at end of file