oh.. and the exception message:



Context log: path="" <b>Internal Servlet Error:</b><br>
<pre>
java.lang.NullPointerException:
        at
org.apache.struts.action.ActionServlet.processValidate(ActionServlet.java:18
95)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1430)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:490)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
        at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:156)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
        at java.lang.Thread.run(Thread.java:475)
</pre>


Thank you.

Jason H. Kim
Quatrix Emerging Technology Team
Phone: 314-993-5858 EXT: 137

-----Original Message-----
From: Jason H. Kim [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 22, 2001 6:14 PM
To: Struts-User Mail Group
Subject: ActionError - java.lang.NummPointer Exception HELP!!!


First, thank you very much in advance for your help.

I am using struts 1.0 and I am getting Null pointer exception when running
validate(Mapping, request) and I am experiencing a coder's block.. if
there's such a thing..

Look at my validate(.., ..) function:

public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
                ActionErrors errors = new ActionErrors();
                log4.debug("Validate:: arraySize = " + getArraySize());
                if (!m_boIsProject && !m_boSigned) {
                        validateNumbers(errors);


                        if (errors.empty()) {
                                validateHours(errors);
                        }
                        log4.debug("================================================");
                        if (errors == null) {
                                log4.debug("2. error is null...");
                                errors = new ActionErrors();
                        }
                        log4.debug("2. error is not null...");
                        if (errors.empty()) {
                                validateComments(errors);
                        }
                }
                return errors;
        }

I am getting logj logs up till log4.debug("2. error is not null..."),
meaning errors did not become null - of course.. But the thing is, I don't
get the very first log message from validateComments(error), which should
execute as the first code inside the method.

the validate mathod was quite long, but I made some helper functions because
I thought it might solve the proble. - but since I am still using the
reference of errors, it will be basically the same, right? So... should  I
create new ActionErrors from my methods and return it? so that my main
validate method does get() to get Iterators and go through it??

Following is my code for validateComments(errors):










private void validateComments(ActionErrors errors) {
                // Validate only iff all numbers are of valid hour.
                log4.debug("Validate:: No error detected so far... Now checking comment
length validation...");
                log4.debug("Validate:: isLengthValid for Sundar hour...");
                for (int i=0; i<getArraySize(); i++) {
                        log4.debug("Validate:: sundayComment["+i+"] = " 
+m_strSundayComment[i]);
                        if (!BusinessRules.isLengthValid(m_strSundayComment[i]))
errors.add("sundayComment["+ i +"]", new
ActionError("error.com.qett.time.invalid.comment.length", "Sunday",
getIndexName(i), BusinessRules.getStringMaxLength()));
                }
                log4.debug("Validate:: isLengthValid for Sundar hour...");
                for (int i=0; i<getArraySize(); i++) {
                        log4.debug("Validate:: mondayComment["+i+"] = " 
+m_strMondayComment[i]);
                        if (!BusinessRules.isLengthValid(m_strMondayComment[i]))
errors.add("mondayComment["+ i +"]", new
ActionError("error.com.qett.time.invalid.comment.length", "Monday",
getIndexName(i), BusinessRules.getStringMaxLength()));
                }
                log4.debug("Validate:: isLengthValid for Sundar hour...");
                for (int i=0; i<getArraySize(); i++) {
                        log4.debug("Validate:: tuesdayComment["+i+"] = "
+m_strTuesdayComment[i]);
                        if (!BusinessRules.isLengthValid(m_strTuesdayComment[i]))
errors.add("tuesdayComment["+ i +"]", new
ActionError("error.com.qett.time.invalid.comment.length", "Tuesday",
getIndexName(i), BusinessRules.getStringMaxLength()));
                }
                log4.debug("Validate:: isLengthValid for Sundar hour...");
                for (int i=0; i<getArraySize(); i++) {
                        log4.debug("Validate:: wednesdayComment["+i+"] = "
+m_strWednesdayComment[i]);
                        if (!BusinessRules.isLengthValid(m_strWednesdayComment[i]))
errors.add("wednesdayComment["+ i +"]", new
ActionError("error.com.qett.time.invalid.comment.length", "Wednesday",
getIndexName(i), BusinessRules.getStringMaxLength()));
                }
                log4.debug("Validate:: isLengthValid for Sundar hour...");
                for (int i=0; i<getArraySize(); i++) {
                        log4.debug("Validate:: thursdayComment["+i+"] = "
+m_strThursdayComment[i]);
                        if (!BusinessRules.isLengthValid(m_strThursdayComment[i]))
errors.add("thursdayComment["+ i +"]", new
ActionError("error.com.qett.time.invalid.comment.length", "Thursday",
getIndexName(i), BusinessRules.getStringMaxLength()));
                }
                log4.debug("Validate:: isLengthValid for Sundar hour...");
                for (int i=0; i<getArraySize(); i++) {
                        log4.debug("Validate:: fridayComment["+i+"] = " 
+m_strFridayComment[i]);
                        if (!BusinessRules.isLengthValid(m_strFridayComment[i]))
errors.add("fridayComment["+ i +"]", new
ActionError("error.com.qett.time.invalid.comment.length", "Friday",
getIndexName(i), BusinessRules.getStringMaxLength()));
                }
                log4.debug("Validate:: isLengthValid for Sundar hour...");
                for (int i=0; i<getArraySize(); i++) {
                        log4.debug("Validate:: saturdayComment["+i+"] = "
+m_strSaturdayComment[i]);
                        if (!BusinessRules.isLengthValid(m_strSaturdayComment[i]))
errors.add("saturdayComment["+ i +"]", new
ActionError("error.com.qett.time.invalid.comment.length", "Saturday",
getIndexName(i), BusinessRules.getStringMaxLength()));
                }
        }




Thank you.

Jason H. Kim
Quatrix Emerging Technology Team
Phone: 314-993-5858 EXT: 137

Reply via email to