struts2 java.lang.StackOverflowError org.apache.struts2.json.JSONWriter

1. 问题描述:

页面通过异步访问action,    action的方法通过map封装数据,struts的result的type设置为json,后台报错

六月 25, 2016 6:54:33 下午 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [default] in context with path [/msf] threw exception [Filter execution threw an exception] with root cause
java.lang.StackOverflowError
    at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:177)
    at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:164)
    at sun.reflect.misc.ReflectUtil.isPackageAccessible(ReflectUtil.java:195)
    at java.beans.Introspector.getBeanInfo(Introspector.java:154)
    at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:177)
    at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:160)
    at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:126)
    at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:352)
    at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:215)
    at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:160)

2.action的代码

package com.cdv.mediastar.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.cdv.mediastar.model.User;
import com.cdv.mediastar.model.UserSessionlog;
import com.cdv.mediastar.service.UserService;
import com.cdv.mediastar.util.PageParameter;
import com.opensymphony.xwork2.ActionSupport;
@Scope("request")
@Controller("logAction")
public class LogAction extends ActionSupport {

    /**
     *
     */
    private static final long serialVersionUID = -1455520770797186253L;

    Map<String, Object> dataMap = new HashMap<String, Object>();

    public Map<String, Object> getDataMap() {
        return dataMap;
    }

    public void setDataMap(Map<String, Object> dataMap) {
        this.dataMap = dataMap;
    }
    @Resource
    private UserService userService;

    public String index(){
        return "index";
    }

    public String list(){
        dataMap.clear();
        PageParameter page = new PageParameter();
        HttpServletRequest request = ServletActionContext.getRequest();
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        String userid = user.getUserid();
        String appName = "Alkaid";
        List<UserSessionlog> sessionlogList = userService.findlog(userid, appName, 0, page.getPageSize());
        int totalCount = userService.countlog(userid, appName);
        int totalPage = totalCount%page.getPageSize()==0?totalCount/page.getPageSize():totalCount%page.getPageSize()+1;
        page.setTotalCount(totalCount);
        page.setTotalPage(totalPage);
        int startNum = 0, stopNum = 0;
        startNum = 1;
        if((startNum+page.getPageSize()-1)<=totalCount){
            stopNum = startNum+page.getPageSize()-1;
        }else{
            stopNum = totalCount;
        }
        dataMap.put("startNum", startNum);
        dataMap.put("stopNum", stopNum);
        dataMap.put("page", page);
        dataMap.put("sessionlogList", sessionlogList);
        return "success";
    }

}

3. 问题排查及解决方案

以上红色部分,向map中添加了两个对象,结果值栈(StackOverflow)溢出。

去掉一个对象page,改为加入String类型的值,错误解决。

时间: 2024-12-29 15:32:18

struts2 java.lang.StackOverflowError org.apache.struts2.json.JSONWriter的相关文章

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFil

项目启动时报错:java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2的jar包版本号为2.1.8,所以类名是没有错误的,而jar包确实加入进去了.jar包加入的方式是通过user library. 问题解决的办法是:将jar包拷贝到WEB-INF下lib文件夹目录,重新启动tomcat问题解决. ================

struts2 java.lang.ClassNotFoundException: org.apache.commons.lang.xwork.StringUtils

struts2.3  action 返回JSON数据调试过程中报错 最终定位到json-plugin的jar包版本不一致导致 struts2-core-2.3.16.3.jar struts2-json-plugin-2.3.16.jar struts2-spring-plugin-2.3.16.3.jar xwork-core-2.3.16.3.jar action返回json格式方法如下:(引至互联网) 1.传统方式JSON输出 HttpServletResponse response =

java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

报这个错是因为加的struts的jar包有问题... 另外,jar包应该放在WEB-INF下的lib文件夹里面,且不必Add to build path,该目录下的jar包会自动引入 使用struts应该加一下核心包: 处理好之后重启tomcat就正常运行了...

spring异常记录-----java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils

今天在练习怎样SSH中进行单元測试的时候出现下列异常: SEVERE: Exception starting filter Struts2 java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:211

Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils

1.错误描述 2014-7-10 23:12:23 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter struts2 java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils at com.opensymphony.xwork2.config.providers.XmlConfigurationProv

java.lang.ClassNotFoundException: org.apache.strut

This is a common error message for a new Struts2 developer. Many Struts 2 related websites have been reported this problem. Overall, when we see a ClassNotFoundException, we should have a reflection that it is very possible that the build path is wro

struts2与struts1整合,java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

原因:我往项目的WEB-INF/lib中导入了struts2基本的包,还有struts1的core包,以及struts2-strut1-plugin的包,但是没有导入commons-loggin-1.3.1这个包,如下图 我打开commons-loggin-1.3.1这个包看了一下,果然找到了这个组件的class文件 看到这个错误的时候,我感觉就应该i啊是commons-logging这个包没有添加导致的,添加上就好了 struts2与struts1整合,java.lang.NoClassDef

【转】用JSON报的一个错误java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeExcept

来源:http://blog.csdn.net/eilent/article/details/6927700 出现错误的原因是因为jar包导入不全. 今天自己写了一个JSON的例子,可以一调用就出了问题,报下面这个异常: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException 上网上搜了一下才知道原来在使用JSON的使用的时候,不光要导入JSON这个包,同时还要导入另

structs2中,启动Tomcat时异常:严重: Exception starting filter struts2 java.lang.NullPointerException

structs2中,已搭建好structs2开发环境,程序无任何问题.但是,部署好项目之后,启动Tomcat时Console报错抛出异常: 严重: Exception starting filter struts2 java.lang.NullPointerException 如下图所示: 出现这个错误的原因是:这是struts-2.1.6版本的一个BUG,配置文件中设置了开发者模式,即structs.xml中包含了<constant name="struts.devMode"