Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld >> Enterprise Java

Pages: 1
Alucard
stranger


Reged: 07/16/08
Posts: 6
Use EJB3 from simple class
      #176309 - 07/26/08 05:28 PM

Hello,

I'm trying to use a stateless bean from a simple class. When I use following in a servlet class (descending from HttpServlet),
Quote:


@EJB
public GatewaySessionLocal bean;




bean variable is filled in and everything's cool.

But when I do the same in a class, descending directly from Object, bean variable stays null.

Are there any specific conditions to be met by a class which tries to access bean in such a way?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Alucard
stranger


Reged: 07/16/08
Posts: 6
Re: Use EJB3 from simple class [Re: Alucard]
      #176314 - 07/26/08 06:01 PM

Got the answer!

EJB objects in POJO classes can only be acquired using InitialContext (At least in Glassfish, which I use).

Excellent resource:
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 4119

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5