Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-9443

BMT Stateful EJB method throwing an Application Exception causes the bean to be destroyed

    XMLWordPrintable

Details

    • Hide

      I have the following scenario:

      A stateful ejb called TestBean with bean managed transaction demarcation and two methods: doSomething, which throws an app exception and doSomethingElse which does nothing.

      From a test client first we make a call to the method doSomething and later on we attempt to make a call to the method doSomethingElse. The result is that the application exception thrown by the doSomething method gets wrapped in an EJBException which causes the bean to be destroyed. When we try to use the bean again, we get a NoSuchEJBException.

      SampleCode
      @ApplicationException(rollback = false)
      public class MyAppException extends Exception {
      
      }
      
      
      @Stateful
      @TransactionManagement(TransactionManagementType.BEAN)
      public class TestBean implements Test {
         public void doSomething() throws MyAppException {
             throw new MyAppException();
         }
      
         public void doSomethingElse() {
             // do something else
         }
      }
      
      public class TestClient {
      	Test test;
      
      	public void test() {
      		// Lookup TestBean instance
      		try {
      			test.doSomething();
      		} catch(MyAppException e) {
      			// Handle App Exception
      		} catch(RuntimeException e) {
      			// Handle RuntimeException
      		} catch(Exception e) {
      			// Handle general Exception s
      		}
      		test.doSomethingElse(); // throws NoSuchEJBException
      	}
      }
      
      
      Show
      I have the following scenario: A stateful ejb called TestBean with bean managed transaction demarcation and two methods: doSomething , which throws an app exception and doSomethingElse which does nothing. From a test client first we make a call to the method doSomething and later on we attempt to make a call to the method doSomethingElse . The result is that the application exception thrown by the doSomething method gets wrapped in an EJBException which causes the bean to be destroyed. When we try to use the bean again, we get a NoSuchEJBException. SampleCode @ApplicationException(rollback = false ) public class MyAppException extends Exception { } @Stateful @TransactionManagement(TransactionManagementType.BEAN) public class TestBean implements Test { public void doSomething() throws MyAppException { throw new MyAppException(); } public void doSomethingElse() { // do something else } } public class TestClient { Test test; public void test() { // Lookup TestBean instance try { test.doSomething(); } catch (MyAppException e) { // Handle App Exception } catch (RuntimeException e) { // Handle RuntimeException } catch (Exception e) { // Handle general Exception s } test.doSomethingElse(); // throws NoSuchEJBException } }

    Description

      If a BMT Stateful EJB method throws an application exception, the exception gets wrapped in an EJBException whichs causes the bean to be destroyed.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              alejogun_jira Alejandro Giraldo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: