Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Commons Validation giving NullPointerException when using "vars" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Commons Validation giving NullPointerException when using "vars"

    Hello all,

    I am trying to use spring modules' commons validations with Spring. Everything works fine when i do not use "vars" (Variables in form field validations).

    I always get the following Error:
    java.lang.NullPointerException
    at org.springmodules.validation.commons.taglib.Javasc riptValidatorTag.doStartTag(JavascriptValidatorTag .java:420)
    at jsp_servlet._web_45_inf._jsp.__branchform._jspServ ice(__branchform.java:402)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java: 33)
    at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run(ServletStubImpl.java:1006)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:419)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:463)
    at weblogic.servlet.internal.TailFilter.doFilter(Tail Filter.java:28)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at com.opensymphony.module.sitemesh.filter.PageFilter .doFilter(PageFilter.java:39)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at org.displaytag.filter.ResponseOverrideFilter.doFil ter(ResponseOverrideFilter.java:125)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at weblogic.servlet.internal.RequestDispatcherImpl.fo rward(RequestDispatcherImpl.java:326)
    at org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:142)
    at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:243)
    at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1141)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:878)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:792)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:461)
    at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:416)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run(ServletStubImpl.java:1006)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:419)
    at weblogic.servlet.internal.TailFilter.doFilter(Tail Filter.java:28)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at com.opensymphony.module.sitemesh.filter.PageFilter .parsePage(PageFilter.java:118)
    at com.opensymphony.module.sitemesh.filter.PageFilter .doFilter(PageFilter.java:52)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at org.displaytag.filter.ResponseOverrideFilter.doFil ter(ResponseOverrideFilter.java:125)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationAction.run(WebAppServletContext.java :6724)
    at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppServletContext.java:3764)
    at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestImpl.java:2644)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:178)



    The validation rule in validation.xml is:
    Code:
    <form-validation>	
    	<formset>
    	   <form name="branch">
    	     <field property="branchCode" depends="required, mask">
    	       	<arg0 key="branchCode.required" />		
    			<var>
    				<var-name>mask</var-name>
    				<var-value>^\d{5}\d*$</var-value>
    			</var>	 
    	     </field> 	
    	   </form>	 
    	</formset>	
    </form-validation>
    When i remove the variable declaration, everything works again.
    Did anyone get similar error?

    Thanks,
    Seshu

  • #2
    I checked out the source code for JavascriptValidatorTag. The error being thrown is on the highlighted line:
    Code:
    Map vars = field.getVars();
                            // Loop through the field's variables.
                            Iterator varsIterator = vars.keySet().iterator();
                            while (varsIterator.hasNext()) {
                                String varName = (String) varsIterator.next();
                                Var var = (Var) vars.get(varName);
                                String varValue = var.getValue();
                                String jsType = var.getJsType();
    
                                // skip requiredif variables field, fieldIndexed, fieldTest, fieldValue
                                if (varName.startsWith("field")) {
                                    continue;
                                }
    
                                if (Var.JSTYPE_INT.equalsIgnoreCase(jsType)) {
                                    results.append("this."
                                        + varName
                                        + "="
                                        + ValidatorUtils.replace(varValue,
                                        "\\",
                                        "\\\\")
                                        + "; ");
                                } else if (Var.JSTYPE_REGEXP.equalsIgnoreCase(jsType)) {
                                    results.append("this."
                                        + varName
                                        + "=/"
                                        + ValidatorUtils.replace(varValue,
                                        "\\",
                                        "\\\\")
                                        + "/; ");
                                } else if (Var.JSTYPE_STRING.equalsIgnoreCase(jsType)) {
                                    results.append("this."
                                        + varName
                                        + "='"
                                        + ValidatorUtils.replace(varValue,
                                        "\\",
                                        "\\\\")
                                        + "'; ");
                                    // So everyone using the latest format doesn't need to change their xml files immediately.
                                } else if ("mask".equalsIgnoreCase(varName)) {
                                    results.append("this."
                                        + varName
                                        + "=/"
                                        + ValidatorUtils.replace(varValue,
                                        "\\",
                                        "\\\\")
                                        + "/; ");
                                } else {
                                    results.append("this."
                                        + varName
                                        + "='"
                                        + ValidatorUtils.replace(varValue,
                                        "\\",
                                        "\\\\")
                                        + "'; ");
                                }
                            }
    
                            results.append(" return this[varName];\"));\n");
                        }

    Comment


    • #3
      figured it out

      it was classpath error. there were multiple versions of some library files.

      HTH somone.

      -S

      Comment

      Working...
      X