You should be able to catch the exception type thrown by the Session Bean and you will
need to include the exception classes in the client. Have to tried calling the EJB from a
plain java client. Do you get the same result.
What JBoss Server and EJB 3 versions are you using
I put together a test and am able to catch the Exception
I'm using JBoss 4.0.4.GA with version of EJB3 bundled with the installer I think
it's RC8
Stateless Session Bean Code
| import javax.ejb.ApplicationException;
| import javax.ejb.Stateless;
|
|
| @Stateless
| @ApplicationException(rollback=false)
| public class MyStatelessSessionBean implements MyStatelessSessionRemote
| {
| public void throwsException() throws MyClientSideException
| {
| System.out.println("about to throw remote exception");
| throw new MyClientSideException("Server Side Exception thrown to the
client");
| }
| }
|
Remote Interface
| import javax.ejb.ApplicationException;
| import javax.ejb.Remote;
|
| @Remote
| public interface MyStatelessSessionRemote
| {
| public void throwsException() throws MyClientSideException;
|
| }
|
Client code
| import javax.naming.InitialContext;
| import junit.framework.TestCase;
|
| public class ClientTestCase extends TestCase
| {
| public void testThrowException()
| {
| try
| {
| InitialContext ctx = new InitialContext();
| MyStatelessSessionRemote slsb =
(MyStatelessSessionRemote)ctx.lookup("/MyStatelessSessionBean/remote");
|
| slsb.throwsException();
| fail("shouldn't get here");
| }
| catch(Exception ex)
| {
| ex.printStackTrace();
| assertTrue((ex instanceof MyClientSideException));
| }
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974472#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...