• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

@EJB static

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !

 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 7029
1341
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ??
 
A timing clock, fuse wire, high explosives and a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic