STRUTS2 label Error: Caught an exception while getting the property values of NULL

Source: Internet
Author: User

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.opensymph Ony.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 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 go in to the Debug.class file to find such a piece of code:

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 ("< Span style= "color: #ff0000;" >caught an exception and getting the property values of</span> "+ O, e);
            }
            Stackvalues.add (New Debugmapentry (O.getclass (). GetName (), values));
        }

        Addparameter ("Stackvalues", stackvalues);

        return result;
  }

Image

An object in root was found to be null, which is the reason for the exception,

Then found that the JSP page has a <s:debug></s:debug> tag, remove the label is normal.

But there is a new problem, the debug tag is debug, but because the debug tag produced a bug ...

Figure out why you need to know why there is a null object in Valuestack.getroot ().

It's about figuring out what valuestack is putting on ... And then... Analysis ...

Continued:

Asked in the forum, no results, calm analysis, the other pages can be normal, but this one page can not, so that the problem of the place in action inside,
Then we find a piece of code: Actioncontext.getcontext (). Getvaluestack (). push (member);
That's the problem, as you can imagine where the null in root came from, and then add an if (member! = null) {}, and the problem is solved.
Specifically do not know who added, used to do, so add an if to judge, is estimated to be used on the page, just a bit does not conform to our code's consistent style.
This is the problem, but also debug to debug to ...





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.