You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Hao Lieu <ha...@gmail.com> on 2011/07/04 04:38:26 UTC

simple stateless question

I got a simple stateless bean

@Stateless
public class CsUndergradCourse implements Course {...}

Course is a plain old java interface.
public interface Course {...}

when i start up my ejb container, i can see in the log info, the following
JNDI binding happening:

1. INFO -
Jndi(name="java:global/cdi-examples/CsUndergradCourse!org.superbiz.cdi.examples.Course")
2. INFO - Jndi(name="java:global/cdi-examples/CsUndergradCourse")

but when i lookup up the following,
   Object object =
ejbContainer.getContext().lookup("java:global/cdi-examples/CsUndergradCourse");

object is null and the following fails
assertTrue(object instanceof CsUndergradCourse);

but if i remove the implements Course, everything works.

Whats going on?  I'm assuming that the JNDI binding in 2. is the object I'm
looking for, but it clearly is not.
Why does implementing the interface change the binding?


-- 
H

Re: simple stateless question

Posted by Hao Lieu <ha...@gmail.com>.
Got it.
So if the stateless implements an interface, the stateless' JNDI is

Object object = ejbContainer.getContext().lookup
  ("java:global/cdi-examples/CsUndergradCourse!org.superbiz.cdi.examples.Course");

and the client only sees it as the interface, not as the full stateless. So
I
was able to do:
assertTrue(object instanceof Course);

and work with the Course interface.
Thanks.



On Mon, Jul 4, 2011 at 5:15 AM, Jean-Louis MONTEIRO <je...@gmail.com>wrote:

> Hi,
>
> As per the spec, without any interface, your stateless is a local view been
> (not a Local nor a Remote).
> That's why you are able to lookup your bean without the interface name at
> the end.
>
> If you really implement an interface, the stateless will be bound to JNDI
> with its local interface.
>
> Then, you need to specify the interface after.
> Have a look to the log info after the "!".
>
> Hope it helps,
> Jean-Louis
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/simple-stateless-question-tp3642851p3643493.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>



-- 
H

Re: simple stateless question

Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Hi,

As per the spec, without any interface, your stateless is a local view been
(not a Local nor a Remote).
That's why you are able to lookup your bean without the interface name at
the end.

If you really implement an interface, the stateless will be bound to JNDI
with its local interface.

Then, you need to specify the interface after.
Have a look to the log info after the "!".

Hope it helps,
Jean-Louis

--
View this message in context: http://openejb.979440.n4.nabble.com/simple-stateless-question-tp3642851p3643493.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.