cancel
Showing results for 
Search instead for 
Did you mean: 

Using @EJB for injection

Former Member
0 Kudos

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

@EJB

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Richar,

The @EJB annotation is supported by the web tier in Netwaever 7.1.

However, the annotations is not supported in the JSPs. This is by the specification. So you can use the @EJB annotation in servlet instead.

Regards,

Diyan

Former Member
0 Kudos

Thanks for replying so quickly Diyan. I am not using the annotation from the JSP but from a bean used by the JSP. The specification seems a little ambiguous here as JSF managed beans are allowed to use injection annotations, so I don't see why it would be a problem for POJOs. The JSP servlet generation engine would not need to cope with annotations in this scenario. However, I will try and use the bean from a servlet and see if that works.