nested exception is java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)] with root cause

private void addOperationLog(JoinPoint joinPoint, Object res, int time) {
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
MpOpLog operationLog = new MpOpLog();
operationLog.setRunTime(time);
operationLog.setReturnVal(JSON.toJSONString(res));
System.out.println("================:"+joinPoint.toString());
Object[] args = joinPoint.getArgs();
Object[] arguments = new Object[args.length];
System.out.println("================:"+args);
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof ServletRequest || args[i] instanceof ServletResponse || args[i] instanceof MultipartFile) {
//ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
//ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response
continue;
}
arguments[i] = args[i];
}
String paramter = "";
if (arguments != null) {
try {
paramter = JSONObject.toJSONString(arguments);
} catch (Exception e) {
paramter = arguments.toString();
}
}
System.out.println("================:"+paramter.toString());
operationLog.setArgs(paramter.toString());
operationLog.setOpTime(new Date());
operationLog.setMethod(signature.getDeclaringTypeName() + "." + signature.getName()); String uerid = AppUtil.getJwtParam("userId");
String userName = AppUtil.getJwtParam("userName"); operationLog.setUserId(StringUtils.defaultIfBlank(uerid, "anonymous"));
operationLog.setUserName(StringUtils.defaultIfBlank(userName, "anonymous")); OpLog annotation = signature.getMethod().getAnnotation(OpLog.class);
if (annotation != null) {
operationLog.setId(UUID.randomUUID().toString().replace("-", ""));
operationLog.setLevel(annotation.level());
operationLog.setContent(getDetail(((MethodSignature)joinPoint.getSignature()).getParameterNames(),
arguments, annotation));
operationLog.setOpType(annotation.operationType().getValue());
operationLog.setOpUnit(annotation.operationUnit());
} tmpOpLogService.insert(operationLog);
}

JSON.toJSONString(joinPoint.getArgs())报错getOutputStream() has already been called for this response的更多相关文章

  1. 【转】JSON.parse() Unexpected token i in JSON at position 2 报错问题

    JSON.parse(): Unexpected token i in JSON at position 2 报错问题 错误代码: var res = "[{id:1,name:'limin ...

  2. C# String.Format格式化json字符串中包含"{" "}"报错问题

    json.Append(String.Format("{\"total\":{0},\"row\":{1}}", lineCount, st ...

  3. 后台返回json字符串 页面js报错 Uncaught SyntaxError: Unexpected identifier

    后台json字符串是 [{"name": "报销申请", "id": "start"}, {"name&quo ...

  4. 利用json模块解析dict报错找不到attribute 'dumps'[python2.7]

    [背景] 环境: RHEL 7.3 版本: python2.7 [错误情况] 写了一个简单的python脚本 将dict转换为json 脚本如下: #!/usr/bin/python #-*- cod ...

  5. 【微信】微信小程序 微信开发工具中新创建的json文件,编译报错VM1781:2 pages/module/module.json 文件解析错误 SyntaxError: Unexpected end of JSON input

    如果新创建报错:编译报错VM1781:2 pages/module/module.json 文件解析错误  SyntaxError: Unexpected end of JSON input 解决方法 ...

  6. JSON.parse解决Unexpected token ' in JSON at position 1报错

     壹 ❀ 引 我们知道JSON.parse能将JSON字符串转变成JS对象,但在一些转换中可能出现Unexpected token ' in JSON at position 1的错误,这是因为被转换 ...

  7. Unexpected token o in JSON at position 1 报错原因

    写在前面的话这个问题在之前做项目时碰到过一次,当时按照网上的做法,去掉JSON.parse()这一层转换后就没有这个报错了,数据也能正常使用,就没多想,也没深究是什么原因. 可是这次又碰到了,所以这次 ...

  8. struts2使用json返回数据,报错:Parent package is not defined: json-default - [unknown location]

    使用struts2的struts-json插件时,一直报错:找不到json-default的位置,下面是我的查错步骤: 1.将struts-json版本更改为低版本,结果还是报这个错 2.重新导入ma ...

  9. PHP“Cannot use object of type stdClass as array” (php在调用json_decode从字符串对象生成json对象时的报错)

    php再调用json_decode从字符串对象生成json对象时,如果使用[]操作符取数据,会得到下面的错误 错误:Cannot use object of type stdClass as arra ...

随机推荐

  1. 【图像处理】Golang 获取JPG图像的宽高

    一.背景 有些业务需要判断图片的宽高,来做一些图片相关缩放,旋转等基础操作. 但是图片缩放,旋转,拼接等操作需要将图片从 JPG 格式转成 RGBA 格式操作,操作完毕后,再转回 JPG 图片. 那如 ...

  2. Prometheus介绍及docker安装方式

    一.介绍 Prometheus是主要基于Go编写,最初在SoundCloud上构建的开源系统监视和警报工具包,它启发于 Google 的 borgmon 监控系统,由工作在 SoundCloud 的 ...

  3. 面试官:请分析一条SQL的执行

    最近一直在写<手撕MySQL系列>文章,我发现自己的切入点有一些问题,虽尝试深入探究MySQL中的一些关键特性,但对于MySQL的知识掌握不太能够形成较好的体系化的知识网络.我感到在对全局 ...

  4. Python 康德乐大药房网站爬虫,使用bs4获取json,导入mysql

    自学两天,写个low点的爬虫代码.自己获取商品价格接口的过程,使用软件 Fiddler 进行抓包进行分析.调用接口进行异常判断

  5. 通过Nginx TCP反向代理实现Apache Doris负载均衡

    概述 Nginx能够实现HTTP.HTTPS协议的负载均衡,也能够实现TCP协议的负载均衡.那么,问题来了,可不可以通过Nginx实现Apache Doris数据库的负载均衡呢?答案是:可以.接下来, ...

  6. 彻底解决Failed to execute goal on project xxxxx

    1.错误内容:Could not resolve dependencies for project 今天在使用mvn clean package命令对一个子项目打包的时候出现如下错误(但是使用mave ...

  7. OpenHarmony 3.1 Beta版本关键特性解析——分布式DeviceProfile

    (以下内容来自开发者分享,不代表 OpenHarmony 项目群工作委员会观点) 成翔 OpenAtom OpenHarmony(以下简称"OpenHarmony")作为分布式操作 ...

  8. 实践GoF的23种设计模式:建造者模式

    摘要:针对这种对象成员较多,创建对象逻辑较为繁琐的场景,非常适合使用建造者模式来进行优化. 本文分享自华为云社区<[Go实现]实践GoF的23种设计模式:建造者模式>,作者: 元闰子. 简 ...

  9. fedora访问win10共享

    sudo mount -t cifs -o username=user,password=123 //192.168.31.20/aa /home/liao/win

  10. mybatis xml 中 trim 多余的符号

    <if test="(mac != null and mac != '') or (roomNo != null and roomNo != '') or (bedNo != null ...