fastjson No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.uti
2017-04-01 00:43
453 查看
1、异常
No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton...
2、情况说明
使用fastjson转换entity为string(String jsonStr=JSON.toJsonString(entity))时报出的异常;
说实话,第一眼看到转json字符串报出SecurityManager异常时,我整个人都蒙b了,这是什么情况?我就是一个实体类转json字符串啊,怎么会爆出这个异常呢?百度这个异常,没有发现一个情况和这个相关。只一步一步的找了。坑死了......
3、原因
entity继承的基类BaseEntity中有一个这样的getter方法,如下:
public String getCurrentAuditor() {
Subject subject = SecurityUtils.getSubject();
if(subject == null) {
return "admin";
}
return subject.getPrincipal().toString();
}
就是这个方法导致了fastjson转化entity为字符串失败,只能先转map再转json字符串了。
No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton...
2、情况说明
使用fastjson转换entity为string(String jsonStr=JSON.toJsonString(entity))时报出的异常;
说实话,第一眼看到转json字符串报出SecurityManager异常时,我整个人都蒙b了,这是什么情况?我就是一个实体类转json字符串啊,怎么会爆出这个异常呢?百度这个异常,没有发现一个情况和这个相关。只一步一步的找了。坑死了......
3、原因
entity继承的基类BaseEntity中有一个这样的getter方法,如下:
public String getCurrentAuditor() {
Subject subject = SecurityUtils.getSubject();
if(subject == null) {
return "admin";
}
return subject.getPrincipal().toString();
}
就是这个方法导致了fastjson转化entity为字符串失败,只能先转map再转json字符串了。
相关文章推荐
- junit集成maven。 No SecurityManager accessible to the calling code, either bound to the org.apache.shir
- org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling c
- org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling c
- org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible to the calling c
- Shiro 集成 No SecurityManager accessible to the calling code....
- shiro报错:No SecurityManager accessible to the calling code
- No SecurityManager accessible to the calling code
- shiro之org.apache.shiro.UnavailableSecurityManagerException: No SecurityManager accessible
- Shiro报错No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.
- Shiro 报错 No SecurityManager accessible(汇总)
- Jmeter返回org.apache.http.NoHttpResponseException: The target server failed to respond解决办法
- Shiro报错-[org.apache.shiro.mgt.AbstractRememberMeManager] - There was a failure while trying to retrieve remembered principals.
- junit+springMVC单元测试异常:org.apache.shiro.UnavailableSecurityManagerException
- jmeter运行报错:org.apache.http.NoHttpResponseException: The target server failed to respond
- org.apache.shiro.realm.AuthorizingRealm - No cache or cacheManager properties have been set. Authorization cache cannot be obtained.
- The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly." 目标程序集不包含服务类型。可能需要调整此程序集的代码访问安全策略。
- org.apache.shiro.realm.AuthorizingRealm - No cache or cacheManager properties have been set. Auth...
- Win7 安装Apache 2.2.4报错:<OS 5>拒绝访问. :Failed to open the WinNT service manager
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误
- windows安装Apache,注册服务出现“(OS 5)拒绝访问。 : AH00369: Failed to open the WinNT service manager..."错误