[ 
https://issues.apache.org/jira/browse/TOMEE-2066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16050383#comment-16050383
 ] 

Svetlin Zarev commented on TOMEE-2066:
--------------------------------------

Shouldn't the first annotation bind FirstBean to 
"java:comp/env/ejb/TestServlet/first"

{code}
@EJB(beanName = "FirstBean", name = "ejb/TestServlet/first")
SessionBean firstByBeanName;
{code}

When I print the context from the servlet, I can see that such reference exists:

{code}
### Context: /comp/env/ejb/TestServlet
Name: first     Class=org.apache.openejb.core.ivm.naming.IntraVmJndiReference
[Reference]: proxy=org.example.SessionBean;deployment=ROOT//FirstBean;pk=null
{code}

My expectation is that the second annotation will look up the bean using that 
reference:
{code}
@EJB(lookup = "java:comp/env/ejb/TestServlet/first")
private SessionBean firstByLookup;
{code}

For instance lookup from servlet using InitialContext works as expected.

PS: That case works on glassfish / wildfly / TomEE 1.7




> Issue with EJB injection
> ------------------------
>
>                 Key: TOMEE-2066
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2066
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Svetlin Zarev
>         Attachments: sample.zip
>
>
> Servlet with:
> {code}
>  @EJB(beanName = "FirstBean", name = "ejb/TestServlet/first")
>     SessionBean firstByBeanName;
>     @EJB(beanName = "SecondBean", name = "ejb/TestServlet/second")
>     SessionBean secondByBeanName;
>     @EJB(lookup = "java:comp/env/ejb/TestServlet/first")
>     private SessionBean firstByLookup;
>     @EJB(lookup = "java:comp/env/ejb/TestServlet/second")
>     private SessionBean secondByLookup;
> {code}
> Expected Output:
> {code}
> FirstBean (by BeanName): org.example.FirstBean
> SecondBean (by BeanName): org.example.SecondBean
> FirstBean (by lookup): org.example.FirstBean
> SecondBean (by lookup): org.example.SecondBean
> {code}
> Actual Output: 
> {code}
> FirstBean (by BeanName): org.example.FirstBean
> SecondBean (by BeanName): org.example.SecondBean
> FirstBean (by lookup): org.example.SecondBean
> SecondBean (by lookup): org.example.SecondBean
> {code}
> Problem:
> "FirstBean (by lookup)" or "SecondBean (by lookup)" are always injected the 
> same instance - i.e. either FirstBean or SecondBean, while FirstBean should 
> be injected FisrtBean, and SecondBean -> SecondBean.
> Attached application that reproduces the issue and prints the naming context



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to