struts2 <debug>标签报错:Caught an exception while getting the property values

J2EE 码拜 9年前 (2015-04-14) 905次浏览 0个评论
 

java.lang.NullPointerException
at com.opensymphony.xwork2.ognl.OgnlUtil.getBeanInfo(OgnlUtil.java:398)
at com.opensymphony.xwork2.ognl.OgnlUtil.getPropertyDescriptors(OgnlUtil.java:344)
at com.opensymphony.xwork2.ognl.OgnlUtil.getBeanMap(OgnlUtil.java:375)
at com.opensymphony.xwork2.ognl.OgnlReflectionProvider.getBeanMap(OgnlReflectionProvider.java:97)
at org.apache.struts2.components.Debug.start(Debug.java:71)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
at org.apache.jsp.WEB_002dINF.jsp.member2Restaurant.searchPartner_jsp._jspx_meth_s_005fdebug_005f0(searchPartner_jsp.java:272)
at org.apache.jsp.WEB_002dINF.jsp.member2Restaurant.searchPartner_jsp._jspService(searchPartner_jsp.java:183)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:164)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:374)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:278)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:236)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
at cn.com.eatlab.web.AuthInterceptor.intercept(AuthInterceptor.java:74)
………..
ERROR ExceptionMappingInterceptor:38 – Caught an exception while getting the property values of null– Class: com.opensymphony.xwork2.ognl.OgnlUtil
File: OgnlUtil.java
Method: getBeanInfo
Line: 398 – com/opensymphony/xwork2/ognl/OgnlUtil.java:398:-1
org.apache.jasper.JasperException: Caught an exception while getting the property values of null – Class: com.opensymphony.xwork2.ognl.OgnlUtil
File: OgnlUtil.java
Method: getBeanInfo
Line: 398 – com/opensymphony/xwork2/ognl/OgnlUtil.java:398:-1
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

debug进去到Debug.class文件发现这样一段代码:

 public boolean start(Writer writer) {
        boolean result = super.start(writer);


        ValueStack stack = getStack();
        Iterator iter = stack.getRoot().iterator();
        List stackValues = new ArrayList(stack.getRoot().size());
        while (iter.hasNext()) {
            Object o = iter.next();
            Map values;
            try {
                values = reflectionProvider.getBeanMap(o);//此处报错
            } catch (Exception e) {
                throw new StrutsException("Caught an exception while getting the property values of " + o, e);
            }
            stackValues.add(new DebugMapEntry(o.getClass().getName(), values));
        }

        addParameter("stackValues", stackValues);

        return result;
  }

图片struts2 <debug>标签报错:Caught an exception while getting the property values

发现root中一个对象为null,此为发出异常的的原因,

接着发现jsp页面有一个<s:debug></s:debug>标签,去掉此标签后就正常了。

但是又产生了一个新的问题,debug标签就是debug用的,却因为debug标签产生bug……

搞清楚为什么就要知道为什么 valueStack.getRoot() 中会有一个 为null的 对象,

也就是要搞清楚valueStack到底是放的什么东西…然后…求分析…

struts2 <debug>标签报错:Caught an exception while getting the property values
是不是下班时间一到,全部闪人了,,,
struts2 <debug>标签报错:Caught an exception while getting the property values
20分
一直看到了,只是不知道怎么帮你分析….  看大神吧 – -!
struts2 <debug>标签报错:Caught an exception while getting the property values
55分
你是不是和spring集成在一起的,如果是的需要在配置文件增加点东西,之前遇到过,刚刚没找到,找到告诉你!
struts2 <debug>标签报错:Caught an exception while getting the property values
引用 3 楼 w_l_o_v_e_c 的回复:

你是不是和spring集成在一起的,如果是的需要在配置文件增加点东西,之前遇到过,刚刚没找到,找到告诉你!

是的。

struts2 <debug>标签报错:Caught an exception while getting the property values
引用 2 楼 shijing266 的回复:

一直看到了,只是不知道怎么帮你分析….  看大神吧 – -!

顶一个也行啊

struts2 <debug>标签报错:Caught an exception while getting the property values
引用 3 楼 w_l_o_v_e_c 的回复:

你是不是和spring集成在一起的,如果是的需要在配置文件增加点东西,之前遇到过,刚刚没找到,找到告诉你!

这大概是个什么问题呢

struts2 <debug>标签报错:Caught an exception while getting the property values
12分
把你的jsp页面贴出来
struts2 <debug>标签报错:Caught an exception while getting the property values
引用 8 楼 w_l_o_v_e_c 的回复:

把你的jsp页面贴出来

<s:debug></s:debug><!--  没有这个标签没问题,加上这个后就报错 -->
exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/aaa/xxx.jsp at line 61

58: </head>
59: 
60: <body>
61: <s:debug></s:debug>
62: 	<div id="container"">
63: 	<div >
64: 				<div >
struts2 <debug>标签报错:Caught an exception while getting the property values
伤不起啊,每次提问都没的什么人回答….难道我不舍得给分么
struts2 <debug>标签报错:Caught an exception while getting the property values
13分
<s:debug/>试试这样写,你单独搞个测试界面越少越好,看看什么个情况!
struts2 <debug>标签报错:Caught an exception while getting the property values
引用 11 楼 w_l_o_v_e_c 的回复:

<s:debug/>试试这样写,你单独搞个测试界面越少越好,看看什么个情况!

我自己冷静分析了一下,其他的页面都可以正常,唯独这一个页面不可以,由此断定出问题的地方在action里面,
然后发现这么一段代码:ActionContext.getContext().getValueStack().push(member);
这就是问题所在,可想而知当时的root里面的null从何而来,于是加一个if(member != null){},问题也算是解决了。
具体不知道是谁添加的,用来干什么的,所以加一个if判断一下,估计是页面上用到,只是有点不符合我们代码的一贯风格。

struts2 <debug>标签报错:Caught an exception while getting the property values
结果就是这样…

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明struts2 <debug>标签报错:Caught an exception while getting the property values
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!