Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

@Resource Injection of SessionContext in backing bean

843844May 18 2010 — edited May 21 2010
I am using Mojarra JSF implementation with Glassfish v3. Dont know really how to find out the mojarra version, but it's the one included with Glassfish.

I use container managed security and would like to secure a backing bean of my web application programmatically. In order to do so, I was following the Java EE Tutorial Vol1 on "VII -> 24 -> Securing an Enterprise Bean Programmatically".

Now, this doesnt seem very complicated for a quick start. When I try it however, the following error is displayed in browser:
"An error occurred performing resource injection on managed bean MyBean"

MyBean looks somewhat like this:
@ManagedBean
@RequestScoped
public class MyBean {

	@Resource SessionContext ctx;

	public String getUserId() {
		Principal callerPrincipal = ctx.getCallerPrincipal();		
		return callerPrincipal.getName();
	}
}
In the JSF Webapp after authenticated, I'd just like to do something like:
Welcome #{myBean.getUserId} 
Anybody have an idea? Stacktrace has too many characters, if anybody likes to see I can post parts.
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 18 2010
Added on May 18 2010
5 comments
3,657 views