tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romain Manni-Bucau (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TOMEE-2066) Issue with EJB injection
Date Thu, 15 Jun 2017 11:08:00 GMT

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

Romain Manni-Bucau commented on TOMEE-2066:
-------------------------------------------

Where did you bind comp/env/ejb/* to do that? I didn't see it in your sample so @EJB will
just defaul to a matching EJB and since both share SessionBean type it means any EJB here.

> 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)

Mime
View raw message