You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by pb...@apache.org on 2007/08/29 05:27:29 UTC

svn commit: r570628 - /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/ValidatorForm.java

Author: pbenedict
Date: Tue Aug 28 20:27:28 2007
New Revision: 570628

URL: http://svn.apache.org/viewvc?rev=570628&view=rev
Log:
STR-2020: Explain that NPE is caused by missing ActionServlet

Modified:
    struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/ValidatorForm.java

Modified: struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/ValidatorForm.java
URL: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/ValidatorForm.java?rev=570628&r1=570627&r2=570628&view=diff
==============================================================================
--- struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/ValidatorForm.java (original)
+++ struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/ValidatorForm.java Tue Aug 28 20:27:28 2007
@@ -103,11 +103,20 @@
      */
     public ActionErrors validate(ActionMapping mapping,
         HttpServletRequest request) {
-        ServletContext application = getServlet().getServletContext();
+        
         ActionErrors errors = new ActionErrors();
-
         String validationKey = getValidationKey(mapping, request);
 
+        ServletContext application;
+        try {
+            application = getServlet().getServletContext();
+        } catch (NullPointerException e) {
+            throw new IllegalStateException(
+                    "Missing ActionServlet instance for bean '" +
+                    mapping.getName() + 
+                    "' (created outside of Struts?)", e);
+        }
+        
         Validator validator =
             Resources.initValidator(validationKey, this, application, request,
                 errors, getPage());