开发者

lift with enterprise java beans

I have troubles with deploying lift application with uses enterprise java beans. There's 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's NullPointerException on line with bean.a, so that means, that the bean haven't 开发者_如何学运维been initialized well. Why?


Not Lift-aware, but @EJB is standardly only available to 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 eligible to use @EJB and have to instead lookup EJBs even though they technically count as a servlet at runtime.

As an alternative to injection you could use lookup. If you are in a Java EE 6 server any java code can lookup the EJB via its standard "java:global" JNDI name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜