This week's book giveaway is in the OCP forum. We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests and have Scott Selikoff and Jeanne Boyarsky on-line! See this thread for details.
I have this problem for the past 3 days, searched the internet during the past days looking for an answer with no use. If internet was a desert i would have been dead by now!
I am sorry if this question seems silly to most of you but yes I am a beginner :s
Now, here is the problem!:
I am trying to inject a local bean into another bean and i keep on getting errors. Based on the code that I am pasting here is the error:
Here is my Local interface and bean
Here is the Bean that's trying to inject BBean
I am using GlassFish and NetBeans to develope and test my project.
BTW I couldn't inject a local bean into a servlet either, I had to make it Remote to get injection to work (JNDI fixed the problem I suppose).
Based on my understanding, since BBean is local, I should use beanName property (or attribute) with @EJB, but it is not working.
I couldn't find a book/tutorial (at least an easy going one) or a resource that explain the dirty work that has to be done just to get resource injection to work, I am talking about DD's that must be configured properly. Examples in tutorials are so straight and nice they even look innocent, but when we try to build the simplest example just to try things Boom, exceptions here blasts there!
I am sorry for the late response. Thank you for the reply and link.
I tried it and now i am getting a RuntimeException as the error message says:
Cannot resolve reference Unresolved Ejb-Ref beans.AABean/b@jndi: @null@beans.BLocal@Session@null
I checked the link and it says that if I don't provide name for @EJB the default value is
<fully-qualified name of declaring class>/<field-name>
in my case it will be:
beans.AABean/b which is the name that appears in the Exception's message.
is there anything that I should do in DD and other configuration files? Just in case here are the contents of
I am injecting a remote Bean into a class member of a servlet.
Please any other suggestions on how to get my local bean to work?
these DD entries are not related to BBean. Your comment implies that there should not be any entries in the DD, which is the case in my application.
Like I mentioned earlier I am using Netbeans and I use wizards, so I have the standard DD and standard packaging.
I am guessing that things are going wrong with Packaging, but I am not configuring anything related to packaging, in other words: I am going the default/standard