java - How to use JNDI to obtain a new Stateful Session Bean, in EJB3? -


I try to use JNDI to get a new state session bean in the servlet (as a local variable) I am doing My doGet () method has the following:

  Bean Bean = (Bean) New Initial Concert (). Lookup ("surname");  

I have tried java: comp / env but all my efforts have inspired naming exceptions.

I am trying to use @Stateful (name = "beanName") and @Stateful (mappedName = "beanName"), using different estimates such as @Stateful

What I needed to do was use the @EJB annotation at the class level on the servlet, as follows:

  @EJB (name =" biennam "); Bean Interface = Bean. Category)  

Then look at the @EJB by the name binding by annotation May Ewa method:

  Bean Bean instance = (Bean) new initial Contaks (). Lookup ("java: comp / env / beanName"); In addition to the plain  @Stateful  annotation, there is no need to do anything in the Bean Class. 


Comments