-
1. Re: Possible Bug?
alrubinger Dec 18, 2008 8:19 PM (in response to green_bean_1)@EJB.name is for the JNDI name of the reference within the ENC. Check your JNDI View, looking under the component (your EJB's deployment) namespace for the correct value.
If you'd like to use the global JNDI name (as you are), use @EJB.mappedName.
Or, designate the target EJB by its name: @EJB.beanName.
S,
ALR -
2. Re: Possible Bug?
alrubinger Dec 18, 2008 8:23 PM (in response to green_bean_1)"green_bean_1" wrote:
So, it seems to me like if two impls share the same interface, JBoss doesn't differentiate them?
If you can provide a use case (unit test) exhibiting this, we can open a JIRA for resolution. :)
S,
ALR -
3. Re: Possible Bug?
jaikiran Dec 19, 2008 12:46 AM (in response to green_bean_1)In addition to what Andrew said, which version of JBossAS do you use?
-
4. Re: Possible Bug?
alrubinger Dec 19, 2008 12:51 AM (in response to green_bean_1)Judging from those JNDI Names, gotta be at least AS 5 CR2. :)
S,
ALR -
5. Re: Possible Bug?
green_bean_1 Dec 22, 2008 5:19 PM (in response to green_bean_1)As for my platform, I am using jboss-5.0.0.GA on OS X 10.5.6 using JDK 1.5.0_16..
In regards to the comments / questions dealing with the mappedName v. name.. the example yields the same results whether I am using mappedName or name. in other words..
@EJB(name="javaEEApplication/HelloWorldStatelessBean/remote-com.di.examples.HelloWorld") HelloWorld helloWorld;
@EJB(name="javaEEApplication/StatelessLifecycle/remote-com.di.examples.HelloWorld") HelloWorld lifecycle;
@EJB(name="HelloWorldStatelessBean") HelloWorld helloWorldBean;
@EJB(name="StatelessLifecycle") HelloWorld lifecycleBean;
all resolve to the same exact EJB even though HelloWorldStatelessBean and StatelessLifecyle are two different beans..
i have tried many variations.. but still no success. it still appears that jboss is making the assumption that a business interface can be implemented by only one EJB.. however, in my example i have two beans implement the same business interface. each ejb has a specific (and different) implementation.. -
6. Re: Possible Bug?
green_bean_1 Dec 22, 2008 5:20 PM (in response to green_bean_1)sorry.. the code should be:
@EJB(mappedName="javaEEApplication/HelloWorldStatelessBean/remote-com.di.examples.HelloWorld") HelloWorld helloWorld;
@EJB(mappedName="javaEEApplication/StatelessLifecycle/remote-com.di.examples.HelloWorld") HelloWorld lifecycle;
@EJB(name="HelloWorldStatelessBean") HelloWorld helloWorldBean;
@EJB(name="StatelessLifecycle") HelloWorld lifecycleBean; -
7. Re: Possible Bug?
green_bean_1 Dec 22, 2008 5:29 PM (in response to green_bean_1)ok.. so.. i lied.. the @EJB(mappedName) variation works.. its just the @EJB(name=) variation that doesn't work..
in my ejb-jar.xml file there is an entry for the StatelessLifecycleBean but not for the HelloWorldStatelessBean.. s -
8. Re: Possible Bug?
alrubinger Dec 22, 2008 9:54 PM (in response to green_bean_1)So you're still exhibiting unexpected behaviour?
Does @EJB.name work as expected (ie resolves properly to the ENC name)? I'd be surprised if it didn't as we're shipping a compliant implementation.
S,
ALR -
9. Re: Possible Bug?
mopuf Dec 23, 2008 2:37 AM (in response to green_bean_1)hi,
IMHO here we deal here with two problems (at least), one of my first question is which is your goal ?
Here are my answers to your problem :
1.The EJBs does JNDI behind the scene and to solve this you must help him a little - with some configuration files.
2.If two bean are implementing the same interface (strategy which is not desirable) then you shod use the beanName attribute to inject the right bean.
In most of the cases you use the EJB without any attribute and let the container to do the look up job.
Why you use the @EJB together with the name ?
Regards,
M -
10. Re: Possible Bug?
green_bean_1 Dec 23, 2008 10:59 AM (in response to green_bean_1)
EJB.name does NOT work. it does NOT correctly "inject" the specific implementation.. How would I verify the ENC name for each specific implementation?
2.If two bean are implementing the same interface (strategy which is not desirable) then you shod use the beanName attribute to inject the right bean.
I am curious why this strategy is undesirable.. Seems like the purpose of OO. Single interface with multiple realizations.. -
11. Re: Possible Bug?
alrubinger Dec 23, 2008 11:10 AM (in response to green_bean_1)"green_bean_1" wrote:
EJB.name does NOT work. it does NOT correctly "inject" the specific implementation.. How would I verify the ENC name for each specific implementation?
You haven't supplied the right ENC name yet, so how can you assert it doesn't work? :P.
Get the ENC Name using JNDIView in the JMX Console."mopuf" wrote:
2.If two bean are implementing the same interface (strategy which is not desirable)
The drawback is that the interface is no longer deterministic. It's a reach to infer this is bad practice, in fact, I think it promotes good design ie. separation of contract and impl.
S,
ALR -
12. Re: Possible Bug?
green_bean_1 Dec 23, 2008 12:27 PM (in response to green_bean_1)So.. I think I have finally narrowed it down with the help of ALR and mopuf. props to you both.
it appears that if I annotate the beans with a specific @Stateless.name and use @EJB.beanName things work fine.
but, if i let the container use the default name (which I understand to be just the unqualified class name) in conjunction an explicit EJB.beanName the injection does not work properly..
does this make sense?