1

I have an application in grails 2.3.11 with zk-grails plugin. when I perform spring security core integration for authentication, the zul pages stop responding, giving the following error: "The server is temporarity out of service Woud you like try again? (Unxpected token <(SyntaxError)) "

1 Answers1

1

This sounds like your security configuration intercepts the Ajax servlet mapped to /zkau (independent of grails).

ZK's client engine expects ajax requests to respond with a JSON like format, and not a redirection to a login page (which is usually html). Hence the unexpected token '<' - html pages usually start with a '<', the response parsing simply fails due to a wrong format.

Your next question might be ... why doesn't ZK's client engine detect redirects on ajax responses? -> Simply because it can't. Already discussed multiple times (e.g. here or there)

A Feature request to support modern browser's API's is already posted for a future version -> ZK-4175 and to improve the error messages ZK-4199.

So as of now you have multiple choices:

  1. for unauthorized AJAX requests to /zkau respond with a 401 (unauthorized) instead of a 302 redirect and configure a client side error-code + reload-uri
  2. instead of a 401 you can return a JSON response that ZK's client engine understands e.g.: {"rs":[["redirect",["https://yourssoserver.com/login.jsp",""]]],"rid":1}

  3. as a last resort customize ZK's client side parser error handling as discussed in the zk forums. and implement your own logic to handle certain non JSON responses.

UPDATE: ZK-4199 has been implemented and will be included in ZK version 8.6.2 (displaying a more meaningful error message)

cor3000
  • 936
  • 1
  • 6
  • 16