2 Replies Latest reply on Sep 19, 2011 10:44 AM by tobias81

    SessionContext.getInvokedBusinessInterface() returns unexpected class




      I have a very simple EJB which is accessible by a local interface as well as a no-interface view.


      public interface SimpleService {

        Class invoker();






      public class SimpleServiceEJB implements SimpleService {



         private SessionContext sessionContext;



         public Class invoker() {

           Class result = sessionContext.getInvokedBusinessInterface();

           return result;





      The EJB contains only one simple method which returns the result of SessionContext.getInvokedBusinessInterface(). The JSR 318 specification defines: “The getInvokedBusinessInterface method returns the session bean business interface or no-interface view(bean class) type through which the bean was invoked.”


      So I write a simple Arquillian based unit test and invoke the EJB by its local interface and by its no-interface view.



      public class SimpleServiceTest {



         private SimpleService simpleService;



         private SimpleServiceEJB simpleServiceEJB;




        public static Archive<?> createTestArchive() {

          return ShrinkWrap.create(WebArchive.class, "test.war").addClasses(SimpleService.class, SimpleServiceEJB.class)

             .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");




        public void testInvoker() {

          assertEquals(SimpleServiceEJB.class, simpleServiceEJB.invoker());

          assertEquals(SimpleService.class, simpleService.invoker());





      I deploy and run this on JBoss 7.0.1.Final and the getInvokedBusinessInterface always returns the SimpleServiceEJB.class, also when I invoke the EJB by its local interface. So the second assertEquals() in my unit test fails because of an expected SimpleService class it but was SimpleServiceEJB.







      My system setup:

      Ubuntu 11.04 (x86_64)

      Java(TM) SE Runtime Environment (build 1.7.0-b147)

      JBoss AS 7.0.1.Final