On Jun 2, 2010, at 12:43 PM, Thiago Veronezi wrote:

> I didnt get the SessionContext injection working, but I got the same object
> by using the following code...

Hmmm.  The original approach you had should be fine.  Alternatively, you could 
look it up like so:

    @Stateful
    @AccessTimeout(value = 1, unit = TimeUnit.MILLISECONDS)
    public static class MyLocalBeanImpl implements MyLocalBean {

        public void method1() {
            System.out.println("Method 1 invoked!");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            try {
                SessionContext sessionContext = (SessionContext) new 
InitialContext().lookup("java:comp/EJBContext");
                sessionContext.getBusinessObject(MyLocalBean.class).method2();
            } catch (NamingException e) {
                throw new RuntimeException(e);
            }
        }

        public void method2() {
            System.out.println("Method 2 invoked!");
        }
    }

On a related note, feel free to create a new test case.  Maybe a new one called 
StatefulReentrancyTest or something.  I've created a little template you can 
copy from here:

  
http://svn.apache.org/repos/asf/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTest.java

If at all possible, can you create a test case the reproduces just the 
sessionContext injection problem?  I tried to reproduce it and had no luck.

-David

Reply via email to