How to get the SessionContext


EJB programming & troubleshooting: How to get the SessionContext

  1. How to get the SessionContext (3 messages)

    How to get the session context from the RemoteObjcet and from that I need to find the pricipale ,So could any one come across this could help me to find out ...
    Assuming this is the code
    I get the remote objcet from looking the home...
    rmObject = HomeObject.create();
    from the above remoteObject i need to get the Context like(getSessionContetx)....

  2. You can open up a method in the remote interface (getTheBeanContext()) and in the bean you can return the session context (remember there is sessioncontext object in every session bean, stateless or stateful). The bean implementation method will be
     public SessionContext getTheBeanContext(){
        return < }

    Just curious, why do you need session context object? It is supposed to be used inside that session bean only.
  3. But is the SessionContext object marshallable so that it can be returned via RMI or RMI-IIOP? Maybe the code that queries the session context needs to be wrapped in a session bean method?

       public Principal getCallerPrincipal() {
         return ctx.getCallerPrincipal();

    Even if you could get the session context back to the caller, would the result of calling getCallerPrincipal() be defined outside the scope of an EJB call?
  4. Hi
    Thanks for ur information,I have a problem my user information getting lost ,So I am loging as Test user to look up the jndi and some where the user is getting changed to System ,So I need to know which component has the problem of using the default user....