Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@EJB static

 
Camilo Diaz
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there:

i hope you can help me
does have this line of code any sense?

@EJB
private static myStatelessEJB ;

and..... what does it mean ?


Thanks !

 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Camilo Diaz wrote:
@EJB
private static myStatelessEJB ;



Is that a typo? Because, it's not going to compile. As for what it means semantically - it's trying to "inject" an EJB into a member of some class. Even semantically, that injection on a static member is only allowed in application clients and for all other components, the injection of an EJB on static fields isn't allowed.

Ofcourse, whatever i said may not make sense, if you are beginning to learn J2EE or EJBs. So feel free to provide more context about your question
 
Camilo Diaz
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the response (Almost nobody answer my questions).

Well... the thing is that i need to use an instance variable of a certain stateless EJB inside a static method. Something like:

@EJB
private static myStatelessEJB myebj;

private static void myMethod()
{
myebj.doStuff();
}

in runtime the application launch a nullpointer exception.
So.... i dont really know what's going on .
Any help ?
 
Camilo Diaz
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well... if anyone wants to help me, i figured out that the real problem is how to inject a variable of a local interface (an ejb with the @Local annotation )inside a static method.

Thnks
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4690
336
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Camilo Diaz wrote:the thing is that i need to use an instance variable of a certain stateless EJB inside a static method.

Well, what is the importance of that usage?
 
Camilo Diaz
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to call a local interface from a POJO within a static method, but... the lookup is not working (launch a NameNotFoundException), any help ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic