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. 网络编程学习——Linux epoll多路复用模型

    前言 后端开发的应该都知道Nginx服务器,Nginx是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器.后端部署中一般使用的就是Nginx反向代理技术. ...

  2. rancher 添加集群

    用rancher的管理账户登录rancher控制台首先创建用户 jinzs,后面用户绑定到要添加的集群上的 其次点全局,出现集群列表 >点添加集群 这里集群名称任意,只要你知道,该名称要对应实际 ...

  3. 『现学现忘』Git基础 — 5、Git的协作模式

    目录 1.分布式工作流程 2.集中式工作流 3.分支工作流 4.GitFlow 工作流(最流行) 5.Forking 工作流(偶尔使用) 6.总结 1.分布式工作流程 与传统的集中式版本控制系统(CV ...

  4. QQ浏览器X5内核问题汇总 转

    常常被人问及微信中使用的X5内核的问题,其实我也不是很清楚,只知道它是基于android 4.2的webkit,版本号是webkit 534.今天正好从X5团队拿到了一份问题汇总,梳理下发出来,给各位 ...

  5. Python多线程Threading爬取图片,保存本地,openpyxl批量插入图片到Excel表中

    之前用过openpyxl库保存数据到Excel文件写入不了,换用xlsxwriter 批量插入图片到Excel表中 1 import os 2 import requests 3 import re ...

  6. Apache Doris ODBC Mysql外表在Ubuntu下使用方法及配置

    Apache Doris 社区 2022 年的总体规划,包括待开展或已开展.以及已完成但需要持续优化的功能.文档.社区建设等多方面,我们期待有更多的小伙伴参与进来讨论.同时也希望多多关注Doris,给 ...

  7. JMeter配置Oauth2.0授权接口访问

    本文主要介绍如何使用JMeter配置客户端凭证(client credentials)模式下的请求 OAuth2.0介绍 OAuth 2.0 是一种授权机制,主要用来颁发令牌(token) 客户端凭证 ...

  8. 【Hadoop】ZooKeeper组件

    目录 一.配置时间同步 二.部署zookeeper(master节点) 1.使用xftp上传软件包至~ 2.解压安装包 3.创建 data 和 logs 文件夹 4.写入该节点的标识编号 5.修改配置 ...

  9. [STL] vector 可变数组

    点击查看代码 #include<iostream> #include<vector> using namespace std; int main() { // 初始化 a 为 ...

  10. [题解] trip

    题目大意 给定一颗大小为 \(N\) 的树, \(1\)的度数不小于 \(2\) .每个点有一个颜色,要么为黑色要么为白色. 从 \(1\) 号点开始游走,计数器初始为 \(0\). 如果当前为黑点计 ...