struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 7751] New: - DynaValidatorForm throws NullPointerException and ClassCastException
Date Fri, 05 Apr 2002 00:03:02 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7751>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7751

DynaValidatorForm throws NullPointerException and ClassCastException

           Summary: DynaValidatorForm throws NullPointerException and
                    ClassCastException
           Product: Struts
           Version: 1.1 Beta 1
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Controller
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: mail@phase.ws


I have a DynaValidatorForm declared in the form-bean like so:
<form-bean name="testDynaForm"   
           type="org.apache.struts.validator.DynaValidatorForm">
          <form-property name="username" type="java.lang.String" />
          <form-property name="password" type="java.lang.String" />
          <form-property name="address" type="java.lang.String" />
          <form-property name="city" type="java.lang.String" />
      </form-bean>
It works great when DynaValidatorForm is a DynaActionForm... But, as soon as I 
swap it with DynaValidatorForm it throws the attached (error1) error. Also, 
when I have the type="org.apache.struts.action.DynaActionForm" and try to cast 
it to a DynaValidatorForm i get a ClassCastException error.

========================== error1 ====================================
java.lang.NullPointerException
	at org.apache.struts.action.DynaActionForm.getDynaProperty
(DynaActionForm.java:539)
	at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:357)
	at org.apache.struts.action.DynaActionForm.reset
(DynaActionForm.java:158)
	at org.apache.struts.validator.DynaValidatorForm.reset
(DynaValidatorForm.java:357)
	at org.apache.struts.util.RequestUtils.createActionForm
(RequestUtils.java:618)
	at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:606)
	at org.apache.jsp.testdynaform$jsp._jspService(testdynaform$jsp.java:76)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service
(JspServlet.java:202)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:382)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at ws.phase.security.filter.URLFilter.doFilter(URLFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:213)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:243)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:190)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2343)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:468)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.ajp.tomcat4.Ajp13Processor.process
(Ajp13Processor.java:429)
	at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495)
	at java.lang.Thread.run(Thread.java:536)
========================== error1 ====================================



========================== error2 ====================================

java.lang.ClassCastException: org.apache.struts.action.DynaActionForm
 at ws.phase.test.TestDynaAction.execute(TestDynaAction.java:59)
 at org.apache.struts.action.RequestProcessor.processActionPerform
(RequestProcessor.java:437)
 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:264)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1109)
 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:470)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
 at ws.phase.security.filter.URLFilter.doFilter(URLFilter.java:96)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:213)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
 at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:243)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
 at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:190)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
 at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
 at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
 at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
 at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
 at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:170)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
 at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
 at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
 at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:429)
 at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:495)
 at java.lang.Thread.run(Thread.java:536) 
========================== error2 ====================================

========================== ActionClassCode ====================================
/*
* LoginAction.java
*
* Created on October 12, 2001, 12:14 AM
*/

package ws.phase.test;

import ws.phase.security.form.LoginForm;

import ws.phase.test.*;

import ws.phase.security.logicbeans.SQLAuthenticatorBean;

import ws.phase.security.databeans.RequestedPathBean;
import ws.phase.security.databeans.LoginRedirectBean;
import ws.phase.security.databeans.RealmBean;
import ws.phase.security.databeans.UserBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.ServletContext;
import javax.servlet.http.Cookie;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;

import java.security.Principal;

import org.apache.struts.action.*;
import org.apache.struts.util.RequestUtils;

import org.apache.struts.validator.DynaValidatorForm;
import org.apache.struts.validator.DynaValidatorActionForm;

import org.apache.commons.beanutils.DynaProperty;
import org.apache.commons.beanutils.DynaClass;

import java.io.*;
import java.util.*;
import java.net.*;
/**
 *
 * @author  Administrator
 * @version 
 */
public class TestDynaAction extends Action{
    HttpServletResponse response = null;

    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
    {   
        DynaValidatorForm dvaf = null;

        this.response = response;
        try{
            dvaf = (DynaValidatorForm)form;

        } catch(Exception ex){
            try{
               PrintWriter pw = response.getWriter();
               ex.printStackTrace(pw);
               pw.flush();
               pw.close();
            } catch (IOException ioex){
            }
           
        }
        
        ActionErrors ae = dvaf.validate(mapping,request);
        servlet.log("Validate");
        if(!ae.empty()){
            servlet.log("Got Errors");
            saveErrors(request,ae);
            servlet.log("Saved Errors");
            servlet.log(mapping.getInput());
            return new ActionForward(mapping.getInput());
        }
        
        DynaClass dc = dvaf.getDynaClass();
        DynaProperty[] dp = dc.getDynaProperties();
        int length = dp.length;
        for(int x = 0; x<length; x++){
            String name = dp[x].getName();
            String value = (String)dvaf.get(name);
            servlet.log("DYNA PROP: " + name + ":" + value);
        }
        
        return mapping.findForward("auth");
    }
}
========================== ActionClassCode ====================================

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message