An Exception error occurred in acegi.

Source: Internet
Author: User

I learned acegi yesterday and found an exception.

Org. acegisecurity. authenticationcredentialsnotfoundexception: An authentication object was not found in the securitycontext <br/> at Org. acegisecurity. intercept. abstractsecurityinterceptor. credentialsnotfound (abstractsecurityinterceptor. java: 375) <br/> at Org. acegisecurity. intercept. abstractsecurityinterceptor. beforeinvocation (abstractsecurityinterceptor. java: 288) <br/> at Org. acegisecurity. intercept. web. filtersecurityinterceptor. invoke (filtersecurityinterceptor. java: 104) <br/> at Org. acegisecurity. intercept. web. filtersecurityinterceptor. dofilter (filtersecurityinterceptor. java: 72) <br/> at Org. acegisecurity. util. filterchainproxy $ virtualfilterchain. dofilter (filterchainproxy. java: 275) <br/> at Org. acegisecurity. UI. logout. logoutfilter. dofilter (logoutfilter. java: 110) <br/> at Org. acegisecurity. util. filterchainproxy $ virtualfilterchain. dofilter (filterchainproxy. java: 275) <br/> at Org. acegisecurity. UI. abstractprocessingfilter. dofilter (abstractprocessingfilter. java: 271) <br/> at Org. acegisecurity. util. filterchainproxy $ virtualfilterchain. dofilter (filterchainproxy. java: 275) <br/> at Org. acegisecurity. context. httpsessioncontextintegrationfilter. dofilter (httpsessioncontextintegrationfilter. java: 249) <br/> at Org. acegisecurity. util. filterchainproxy $ virtualfilterchain. dofilter (filterchainproxy. java: 275) <br/> at Org. acegisecurity. util. filterchainproxy. dofilter (filterchainproxy. java: 149) <br/> at Org. acegisecurity. util. filtertobeanproxy. dofilter (filtertobeanproxy. java: 98) <br/> at Org. apache. catalina. core. applicationfilterchain. internaldofilter (applicationfilterchain. java: 235) <br/> at Org. apache. catalina. core. applicationfilterchain. dofilter (applicationfilterchain. java: 206) <br/> at Org. apache. catalina. core. standardwrappervalve. invoke (standardwrappervalve. java: 230) <br/> at Org. apache. catalina. core. standardcontextvalve. invoke (standardcontextvalve. java: 175) <br/> at Org. apache. catalina. core. standardhostvalve. invoke (standardhostvalve. java: 128) <br/> at Org. apache. catalina. valves. errorreportvalve. invoke (errorreportvalve. java: 104) <br/> at Org. apache. catalina. core. standardenginevalve. invoke (standardenginevalve. java: 109) <br/> at Org. apache. catalina. connector. coyoteadapter. service (coyoteadapter. java: 261) <br/> at Org. apache. coyote. http11.http11processor. process (http11processor. java: 844) <br/> at Org. apache. coyote. http11.http11protocol $ http11connectionhandler. process (http11protocol. java: 581) <br/> at org.apache.tomcat.util.net. jioendpoint $ worker. run (jioendpoint. java: 447) <br/> at java. lang. thread. run (thread. java: 619)

 

The source code is as follows:

If (securitycontextholder. getcontext (). getauthentication () = NULL) {<br/> credentialsnotfound (messages. getmessage ("abstractsecurityinterceptor. authenticationnotfound ", <br/>" an authentication object was not found in the securitycontext "), object, ATTR); <br/>}
We can see that the exception is thrown because getauthentication () is null, but from the doc point of view, if httpsessioncontextintegrationfilter is configured, you should set "before executing other filters, determine whether a securitycontext already exists in the user's session. If securitycontext exists, put it in securitycontextholder for use by other parts of spring security. If it does not exist, create a securitycontext and put it in securitycontextholder for other parts of spring security .". From the above, it should be that context is not null, but getauthentication () is null. It is because the authentication object without authorization is blank, but the exceptiontranslationfilter I configured. So this problem has not been solved yet. It took more than two hours last night.

 

This morning, I suddenly thought of it, because the exceptiontranslationfilter was configured before filterinvocationinterceptor, and the exception was not captured by the exceptiontranslationfilter, So I replaced the two with the following sequence and the result was done .. When this exception occurs, the authenticationentrypoint attribute configured in predictiontranslationfilter is automatically redirected.

 

Solve the problem ..

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.