2

Can anyone tell me how to get user name in session bean correctly? In our application we do it by calling this method:

@Resource
private EJBContext _context;

private String getUserName() {
    return _context.getCallerPrincipal().getName();
}

And this works fine till everything's fine. But when we get some 500 or 404 error and redirect user to corresponding page (which is set in web.xml) this method returns "WLS KERNEL" as user name. How to get correct user name in this case?

mykola
  • 1,736
  • 5
  • 25
  • 37
  • 2
    Does this also happen if you just use `#{request.remoteUser}` straight in your JSF error page without a long detour through an EJB? (or `${pageContext.request.remoteUser}` if you're still fiddling with old JSPs). – BalusC Oct 03 '11 at 15:01
  • Thanks, BalusC! Actually, we need user name exactly in EJB to pass it to database, so it wasn't detour but getting it from request didn't come to my mind at all. :) – mykola Oct 04 '11 at 08:37
  • Oh, you were asking this with JSF tag and you're returning it unmodified from an EJB method to the caller, so I thought you needed it in JSF side. – BalusC Oct 04 '11 at 11:21

0 Answers0