0

SecurityContext null in View Model class associated with ZK window intermittently

asked 2012-05-21 19:52:01 +0800

vgadewar gravatar image vgadewar
6

We are facing strange issue in application intermittently.

ZK and Spring Version
ZK 6.01 framework
Spring 2.5
zkspring3.0
MVVM model

We have user management functionality. UserVM is value model class associated with window.

<window border="normal"
id="userManagementWnd" height="800px"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init(userVm)"
validationMessages="@id('vmsgs')" >

We have defined below method in UserVM class.

private UserDetails getUser() {
log.info("Calling getUser() - Get authentication object from sercurity context");
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null ) {
ZapScopeUserContext userCtx = (ZapScopeUserContext)auth.getPrincipal();
log.info("User context object - " + userCtx);
return userCtx;
} else {
log.info("Authentication object is NULL.");
return null;
}
}

We are getting null value for authentication object after some time.
Authentication auth = SecurityContextHolder.getContext().getAuthentication();

When we restart tomcat then issue is resolved it works for some time and then issue starts happening again.

We also see below exceptions in logs but not sure whether that's related to this particular issue.

SEVERE: Failed to invoke org.zkoss.bind.tracker.impl.BindUiLifeCycle@5560c7a8
java.lang.IllegalStateException: UI can't be modified in the rendering phase
at org.zkoss.zk.ui.impl.UiVisualizer.getAttrRespMap(UiVisualizer.java:299)
at org.zkoss.zk.ui.impl.UiVisualizer.addSmartUpdate0(UiVisualizer.java:254)
at org.zkoss.zk.ui.impl.UiVisualizer.addSmartUpdate(UiVisualizer.java:238)

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-05-29 01:28:04 +0800

paowang gravatar image paowang
140 6

I think this might help: http://forum.springsource.org/showthread.php?57988-getAuthentication()-is-null

link publish delete flag offensive edit

answered 2012-05-29 03:46:44 +0800

vgadewar gravatar image vgadewar
6

Yes this helps. Thank you

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-05-21 19:52:01 +0800

Seen: 335 times

Last updated: May 29 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More