Thread: Access EJB using dependency injection from managed bean


Permlink Replies: 3 - Pages: 1 - Last Post: Jan 15, 2007 11:30 PM Last Post By: mulkers
user537054

Posts: 7
Registered: 10/17/06
Access EJB using dependency injection from managed bean
Posted: Oct 17, 2006 4:12 AM
Click to report abuse...   Click to reply to this thread Reply
Hello,

I've built a JSF application. I want to access a session bean using EJB3 dependency injection but I keep having HTTP 500 error.
When I try to access the same session bean from a servlet, there is no problem.
When I access my session from my managed bean using standard context lookup I have no problem either.

Would it be that the @EJB annotation is only valid for servlets and not for other type of component (like a JSF managed bean) ?

Thanks for hint.

Olivier
user537054

Posts: 7
Registered: 10/17/06
Re: Access EJB using dependency injection from managed bean
Posted: Oct 19, 2006 5:51 AM   in response to: user537054 in response to: user537054
Click to report abuse...   Click to reply to this thread Reply
Additional information: I did redeploy my application under glassfish it seems to work fine, ie. the EJB gets injected in the managed bean using @EJB annotation.

I would be grateful if someone could hint me about why it does not seem to work in oc4j 10.1.3.1.0 ?

Thanks

Olivier
Raam

Posts: 78
Registered: 12/14/06
Re: Access EJB using dependency injection from managed bean
Posted: Jan 15, 2007 8:06 PM   in response to: user537054 in response to: user537054
Click to report abuse...   Click to reply to this thread Reply
Hi,

I have a same problem right now.

Can you pl. let me know if you found the solution.

-Rama
mulkers

Posts: 21
Registered: 01/13/00
Re: Access EJB using dependency injection from managed bean
Posted: Jan 15, 2007 11:05 PM   in response to: Raam in response to: Raam
Click to report abuse...   Click to reply to this thread Reply
DI is not supported for any kind of application class in a J2EE 5 application.
http://forums.oracle.com/forums/thread.jspa?threadID=447310

If you have a look at the J2EE 5 spec, the classes where DI is supported are listed on page 64.

Component classes supporting injection
Servlet: servlets, servlet filters, event listeners
JSP: tag handlers, tag library event listeners
JSF: scoped managed beans
JAX-WS: service endpoints, handlers
EJB: beans, interceptors
Java EE platform: main class (static), login callback handler


So if you want to use DI from a JSF scope managed bean, it must be supported.
Robin
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums