-
1. Re: How to get the current user in a SessionBean from the Se
jaikiran Aug 1, 2006 9:42 AM (in response to heinrich)String user = sessionCtx.getCallerPrincipal().getName()
-
2. Re: How to get the current user in a SessionBean from the Se
heinrich Aug 2, 2006 2:25 AM (in response to heinrich)hey, thanks alot!
-
3. Re: How to get the current user in a SessionBean from the Se
beherenow Apr 8, 2008 7:24 AM (in response to heinrich)That's right but..
How do you get the current sessionContext? -
4. Re: How to get the current user in a SessionBean from the Se
jaikiran Apr 8, 2008 8:13 AM (in response to heinrich)"beherenow" wrote:
That's right but..
How do you get the current sessionContext?
There's a callback method setSessionContext which gets called by the container. See this for more details http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/ejb/SessionBean.html#setSessionContext(javax.ejb.SessionContext)
You can use this method to store the sessionContext:private SessionContext sessionContext; public void setSessionContext(SessionContext sessCtx) { this.sessionContext = sessCtx; }
-
5. Re: How to get the current user in a SessionBean from the Se
beherenow Apr 9, 2008 4:00 AM (in response to heinrich)yes, thats true.
But my problem is that i want to get the sessionContext from the Controller of my application. I put that code into the bean to reference:
@Stateless
public class ProcessPaymentBean implements ProcessPaymentLocal{
@Resource SessionContect sessionContext;
//private SessionContext sessionContext;
public void setSessionContext(SessionContext sessCtx) {
this.sessionContext = sessCtx;
}
public SessionContext getSessionContext(){
return this.sessionContext;
}
But sessionContext is ever null. What I must do? Thanks -
6. Re: How to get the current user in a SessionBean from the Se
beherenow Apr 9, 2008 4:08 AM (in response to heinrich)I'm not using the ejb like entity associated to the DB, may it be the problem?
Then, how can I get the sessionContext?
"The container calls the setSessionContext() method after the instance creation". Maybe not works.
Thanks!