Spring Security + WebSocket——@MessageMapping中Authentication为NULL解决方案之一
问题描述
2020-08-06 15:55:53.988 ERROR 29260 --- [boundChannel-17] .WebSocketAnnotationMethodMessageHandler : Unhandled exception from message handler methodjava.lang.NullPointerException: nullat cn.edu.zstu.shihua.xihu.controller.WebSocketController.handleMsg(WebSocketController.java:33) ~[classes/:na]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:171) ~[spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:120) ~[spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMatch(AbstractMethodMessageHandler.java:565) [spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler.handleMatch(SimpAnnotationMethodMessageHandler.java:511) [spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler.handleMatch(SimpAnnotationMethodMessageHandler.java:94) [spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessageInternal(AbstractMethodMessageHandler.java:520) [spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessage(AbstractMethodMessageHandler.java:454) [spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.support.ExecutorSubscribableChannel$SendTask.run(ExecutorSubscribableChannel.java:144) [spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181]at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181]at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
解决方案
在自定义的Spring Security 配置CustomWebSecurityConfig extends WebSecurityConfigurerAdapter 中删除相关路径
参考文章
Websocket Authentication and Authorization in Spring
SecurityContextHolder.getContext().getAuthentication()为null的问题
Spring Security + WebSocket——@MessageMapping中Authentication为NULL解决方案之一相关推荐
- Spring Security应用程序中的su和sudo
很久以前,我从事的项目具有很强大的功能. 有两个角色:用户和主管. 主管可以以任何方式更改系统中的任何文档,而用户则更受工作流约束的限制. 当普通用户对当前正在编辑和存储在HTTP会话中的文档有疑问时 ...
- spring security CSRF 问题 Invalid CSRF Token 'null' was found on ......
1. 问题 前面几篇博客 spring security在集成spring boot的微服务框架后,实现了cas认证和权限控制.但是在使用 postman 进行调用的时候出现这个问题 HTTP Sta ...
- 基于Spring Security的AJAX请求需要登录的解决方案
基于Spring Security的AJAX请求需要登录的解决方案 参考文章: (1)基于Spring Security的AJAX请求需要登录的解决方案 (2)https://www.cnblogs. ...
- Spring Security 3.1 中功能强大的加密工具 PasswordEncoder
去年发生的密码泄漏事件,我们也对密码加密做了重新研究. 在筛选加密方法的过程中,发现了Spring Security 3.1.0版本中提供了新的PasswordEncoder,它的加密方法非常给力! ...
- Spring Security 3.1 自定义 authentication provider
来源:http://www.xeclipse.com/?p=1359 前言 在使用Spring Security的时候,遇到一个比较特殊的情况,需要根据用户名.邮箱等多个条件去验证用户或者使用第三方的 ...
- java ldap操作实例_Java Spring Security示例教程中的2种设置LDAP Active Directory身份验证的方法...
java ldap操作实例 LDAP身份验证是世界上最流行的企业应用程序身份验证机制之一,而Active Directory (Microsoft为Windows提供的LDAP实现)是另一种广泛使用的 ...
- Java Spring Security示例教程中的2种设置LDAP Active Directory身份验证的方法
LDAP身份验证是全球范围内最流行的企业应用程序身份验证机制之一,而Active Directory (Microsoft针对Windows的LDAP实现)是另一种广泛使用的LDAP服务器. 在许多项 ...
- Spring MVC,Thymeleaf,Spring Security应用程序中的CSRF保护
跨站点请求伪造(CSRF)是一种攻击,它迫使最终用户在当前已通过身份验证的Web应用程序上执行不需要的操作. 如果您使用Spring Security 3.2及更高版本,在Spring MVC / T ...
- spring security 3.1中条用js方法登陆后无法回调
1. 假如以下面的方式提交 <body> ${SPRING_SECURITY_LAST_EXCEPTION.message} <form action="j_spring_ ...
最新文章
- dosbox edit.exe 如何使用_如何实现摄影后期无限色彩调色?Infinite Color
- 这款 网络排查 神器,运维用了都说好,赶紧收藏~
- 步步为营(十六)搜索(二)BFS 广度优先搜索
- zookeeper的安装及配置教程(步骤详尽)
- 【Pytorch神经网络理论篇】 13 深层卷积神经网络介绍+池化操作+深层卷积神经网络实战
- 2014年计算机初级应用考试是,2014年国硕士研究生入学统一考试计算机基础试题...
- 关系型数据库和非关系型数据库的区别
- 中国女排代言作业帮直播课,作业帮累计用户已超8亿
- java react_2019JAVA最新课程-React从入门到实战(新)
- KMeans聚类算法思想与可视化
- apt-get指令的autoclean,clean,autoremove的区别
- bzoj3162 独钓寒江雪
- python读取pcd文件_(一)读取PCD文件
- ORACLE中的INTERVAL
- 为什么黑客用python-《Python绝技》:运用Python成为顶级黑客
- java弹窗设置为不可关闭_javascript实现无法关闭的弹框
- 800-C++ throw(抛出异常)详解
- .pfx格式和.Cer格式的区别
- http://cs.dartmouth.edu/~xy/blog/facel/
- 【HSJFramework】Unity时间管理TimeManger计时器
热门文章
- http://www.cnblogs.com/Bear-Study-Hard/archive/2008/03/26/1123267.html
- acm java输入输出_在竞赛ACM Java处理输入输出
- 心态很容易受别人影响_为什么说缠论中的走势中枢容易影响短线买卖交易心态?...
- php数组修改键值,php数组中子数组如何修改键值
- linux 查询内存和核心数,Linux下查看操作系统信息、内存情况及cpu信息:cpu个数、核心数、线程数...
- linux系统root默认密码是多少钱,linux root默认密码忘记后的解决方法
- NLP jieba分词源码解析
- python staticmothed classmethod
- 空值替换为0_「Excel」是零值还是空值,你可以自由掌控
- Navicat mysql 加索引_mysql 索引 (Navicat添加索引)