0

Getting wierd NullPointerException when using Shiro

asked 2013-08-13 10:38:02 +0800

Loekke gravatar image Loekke
15 2

Hi.

I'm using zk CE 6.5.2 and Shiro 1.2.2. I'm using Jetty8 Maven plugin (for development), but it also happens on Tomcat7 (Continuous Integration) when deployed.

When doing the following:

SecurityUtils.getSubject().logout();
Executions.sendRedirect("/");

I get a NullPointerException dialog in zk, before the redirect kicks in. I get the following error in my log:

org.zkoss.zk.ui.impl.UiEngineImpl handleError:1359 SEVERE: java.lang.NullPointerException at org.zkoss.zk.ui.AbstractComponent.getAttachedUiEngine(AbstractComponent.java:337) at org.zkoss.zk.ui.AbstractComponent.disableClientUpdate(AbstractComponent.java:1765) at org.zkoss.zul.Popup.service(Popup.java:177) at org.zkoss.zk.ui.impl.DesktopImpl.service(DesktopImpl.java:701) at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1201) at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:600) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:482) at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:491) at javax.servlet.http.HttpServlet.service(HttpServlet.java:755) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:643) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1331) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1302) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:448) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:377) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) at org.eclipse.jetty.server.Server.handle(Server.java:360) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:900) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:954) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:851) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) at java.lang.Thread.run(Thread.java:722)

Not having 1500 reputation, I cannot create the actual tags "Shiro" and "Redirect".

I'm guessing this means that Shiro's Subject.logout() method does something to the session that zk doesn't expect. Since none of my classes are involved in provoking this error, does anyone have any ideas what to do about this?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-13 12:05:47 +0800

Bobzk gravatar image Bobzk
428 1 5

updated 2013-08-13 12:08:57 +0800

I was having the same problem so I just do :

            # 
            # warning, do not use   
            # currentUser.logout()
            # as ZK does not like it.
            # invalidate the session and redirect as per below.
            #

            desktop = Executions.getCurrent().getDesktop()
            session = desktop.getSession()
            session.invalidate()
            Executions.sendRedirect(None)

Note, this is Python code but you get the gist.

p.s. I have to add, using Shiro is much easier/simple than using Spring - I love it.

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2013-08-13 10:38:02 +0800

Seen: 35 times

Last updated: Aug 13 '13

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