Skip to main content
1-Visitor
December 18, 2013
Solved

IllegalAccessError while accessing sessionContext object.

  • December 18, 2013
  • 1 reply
  • 1959 views

I am getting nested exception java.lang.IllegalAccessError: tried to access field wt.method.MethodContext.sessionContext. my code snippet looks like

try {

MethodContext methodcontext = MethodContext.getContext();

if (methodcontext != null && methodcontext.sessionContext != null

&& methodcontext.sessionContext.toString().contains("authenticationName")){

return SessionHelper.manager.getPrincipal().getName();

} else {

return EMPTY_STRING;

}

} catch (Exception e) {

return EMPTY_STRING;

}

methodcontext.sessionContextgetting an error so couldn't even catch it, it is terminating flow of execution, I check the Apache Conf settings and all looks good. The logged in user is in session just getting an error on sessionContext. Any help around it would be appreciated.

Best answer by jessh

I'm betting you took old customization code that was

  1. Compiled in an older release,
  2. Not re-compiled with the latest release,
  3. Using an unsupported API (the sessionContext field is not supported), and
  4. Tried to run it in 10.2 M010

If so, then that explains everything there is no such publicly accessible field in 10.2 M010. There is, however, a getSessionContext() method -- though it also is not a supported API currently.

[Unsupported APIs are subject to change at any time without notice.]

1 reply

jessh12-AmethystAnswer
12-Amethyst
December 19, 2013

I'm betting you took old customization code that was

  1. Compiled in an older release,
  2. Not re-compiled with the latest release,
  3. Using an unsupported API (the sessionContext field is not supported), and
  4. Tried to run it in 10.2 M010

If so, then that explains everything there is no such publicly accessible field in 10.2 M010. There is, however, a getSessionContext() method -- though it also is not a supported API currently.

[Unsupported APIs are subject to change at any time without notice.]

12-Amethyst
December 19, 2013

It looks like you could get nearly the same result with

MethodContext.getContext().mbean.getUserName()

though this returns null rather than EMPTY_STRING when the user is not known.