Actually, you should use the @EJB annotation on instance members not on static ones. If you think it over, this totally makes sense, because the EJB injected should not be shared by multiple threads, something you cannot guarantee if you inject it into a static variable.
On the other hand, the injection can only happen on container-managed classes, like a Servlet, another Enterprise Java Bean component, even JSP or JSF, but you cannot make the automatic injection happen in helper classes. For those cases, you will need to use JNDI as in the old days.
I hope this helps!
posted 9 years ago
Thank you Edwin for the prompt reply.
Can you please elaborate further on "use JNDI as in the old days"?
Edwin Dalorzo wrote:Actually, you should use the @EJB annotation on instance members not on static ones.
Actually, looking at what Venus seems to be doing, it appears to be an "application client" (with a main method). Injection in application client's requires the member being injected to be static.
And furthermore, each application server has its own way to running an application client (in an application client container). Venus, which application server and which version of the server do you use? The application server documentation will give you more details on how to run the application client.
Are you sure that you deployed the SessionBeans? And secondly, there is a serious error in you code
you should inject the interface
JNDI sees the business interface, not the class itself. Depending on whether you will use methods from the local or remote interface, you should inject the correct interface - then the right session bean will be injected
SCJP, SCWCD, OCUP
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
ScroogeXHTML - small and flexible RTF to HTML converter library