Elevator with java beans

I have problems deploying an elevator application using enterprise java beans. Here is a simple example:

@Stateless
class TestEJB {
 def a = "hello"
}

object TestApi extends XMLApiHelper{
 @EJB
 private var bean:TestEJB = _
 def createTag(a:NodeSeq) = 
 def dispatch: LiftRules.DispatchPF = {
  case Req("test" :: Nil, "", GetRequest) =>
   () => PlainTextResponse( bean.a )
 }
}

There is a NullPointerException in line with bean.a, so this means that it was beannot initialized well. Why?

+5
source share
1 answer

Not Lift-aware, but @EJB is only available by default for servlet, filter, context listener, jsf managed beans, ejbs, webbeans and other Java EE components. Note. JSP classes, due to their dynamic generation / compilation, are not allowed to use @EJB and must search for EJBs, even if they are technically considered a servlet at runtime.

. Java EE 6, Java- EJB java: global. JNDI.

+2

All Articles