[jboss-jira] [JBoss JIRA] (JBAS-9443) BMT Stateful EJB method throwing an Application Exception causes the bean to be destroyed

Carlo de Wolf (Updated) (JIRA) jira-events at lists.jboss.org
Thu Oct 20 16:07:45 EDT 2011


     [ https://issues.jboss.org/browse/JBAS-9443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carlo de Wolf updated JBAS-9443:
--------------------------------

                Labels: community community_contributor_needed  (was: )
              Assignee:     (was: Carlo de Wolf)
    Steps to Reproduce: 
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.

{code:title=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
	}
}

{code}

  was:

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.

{code:title=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
	}
}

{code}


    
> BMT Stateful EJB method throwing an Application Exception causes the bean to be destroyed
> -----------------------------------------------------------------------------------------
>
>                 Key: JBAS-9443
>                 URL: https://issues.jboss.org/browse/JBAS-9443
>             Project: Legacy JBoss Application Server 6 
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: EJB
>    Affects Versions: 6.1.0
>         Environment: Windows XP, JDK 1.6
>            Reporter: Alejandro Giraldo
>              Labels: community, community_contributor_needed
>
> If a BMT Stateful EJB method throws an application exception, the exception gets wrapped in an EJBException whichs causes the bean to be destroyed.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list