Skip to Content
Former Member
Jun 21, 2007 at 10:08 AM

Using @EJB for injection


I have tried unsuccessfully to get this working. I am using the Converter example and have adapted it so that the JSP uses a bean to get it's data. The bean calls the ConverterBean EJB to supply this data. If I use the old way of looking up an EJB through JNDI and an initial context it works fine. However, adapting the code to use the JEE 5 annotations I run into problems, I've tried both of the following and neither work:

// Use default naming


private ConverterLocal converter;

// Use explicit naming:

@EJB (name="Converter")

private ConverterLocal converter;

In both situations converter is null when I come to use it. Does the @EJB annotation work from the web tier in Netweaver 7.1? I have also tried using java:comp/env/Converter in the explicit naming method without success.