Hi,

I'm working on a Struts/Tiles web app with Websphere 5.1.2 and Struts 1.2.4

I'm getting exceptions when trying to use the Validator framework.

After debugging, it almost seems as if the strut-config.xml is not being 
properly digested.

The property maps of the Plug-Ins are always null.

Thus, the ValidatorPlugIn does not know that I've specified a "pathnames" 
property.

Here's my struts-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts 
Configuration 1.1//EN"
                               
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd";>

<struts-config>

    <!-- Data Sources -->
    <data-sources>
    </data-sources>

    <!-- Form Beans -->
    <form-beans>
        <form-bean name="reconWorkqueueActionForm" 
type="com.sscims.palms.gui.workqueue.recon.ReconWorkqueueActionForm">
        </form-bean>
        <form-bean name="reconActionForm" 
type="com.sscims.palms.gui.recon.ReconActionForm">
        </form-bean>
        <form-bean name="progressActionForm" 
type="com.sscims.palms.gui.recon.progress.ProgressActionForm">
        </form-bean>
        <form-bean name="loginActionForm" 
type="com.sscims.palms.gui.LoginActionForm">
        </form-bean>
        <form-bean name="tmvDetailsActionForm" 
type="com.sscims.palms.gui.recon.tmvdetails.TMVDetailsActionForm">
        </form-bean>
        <form-bean name="analysisActionForm" 
type="com.sscims.palms.gui.recon.analysis.AnalysisActionForm">
        </form-bean>            
        <form-bean name="cashActionForm" 
type="com.sscims.palms.gui.recon.cash.CashActionForm">
        </form-bean>
        <form-bean name="positionActionForm" 
type="com.sscims.palms.gui.recon.cash.PositionActionForm">
        </form-bean>
        <form-bean name="checklistActionForm" 
type="com.sscims.palms.gui.recon.cash.ChecklistActionForm">
        </form-bean>
    </form-beans>

    <!-- Global Exceptions -->
    <global-exceptions>
    </global-exceptions>

    <!-- Global Forwards -->
    <global-forwards>
        <!-- Default forward to "Welcome" action -->
        <!-- Demonstrates using index.jsp to forward -->
        <forward name="loginPage" path="/showLogin.do" redirect="true">
        </forward>
    </global-forwards>

    <!-- Action Mappings -->
    <action-mappings>
        <!-- Default "Welcome" action -->
        <!-- Forwards to Welcome.jsp -->
        <action path="/PALMSBase" type="com.sscims.palms.gui.PALMSBaseAction">
        </action>
        <action path="/login" type="com.sscims.palms.gui.LoginAction" 
input="/pages/login/login.jsp" name="loginActionForm" scope="request" 
validate="true">
                <forward name="success" path="/defaultPageDispatcher.do" 
redirect="false">
                </forward>
        </action>
        <action path="/logout" type="com.sscims.palms.gui.LogoutAction" >
                <forward name="success" path="/showLogin.do" redirect="true">
                </forward>
        </action>
        <action path="/showLogin" type="com.sscims.palms.gui.ShowLoginAction" 
validate="false">
                <forward name="success" path="/pages/login/login.jsp" >
                </forward>
        </action>
        <action path="/recon/showWorkqueue" 
type="com.sscims.palms.gui.workqueue.recon.ShowReconWorkqueueAction">
                <forward name="success" path="/pages/workqueue/workqueue.jsp">
                </forward>
        </action>
        <action path="/recon/showReconWorkqueue" 
type="com.sscims.palms.gui.workqueue.recon.ShowReconWorkqueueAction" 
name="reconWorkqueueActionForm" scope="request" 
input="/pages/workqueue/recon/recon.jsp">
                <forward name="success" path="/pages/workqueue/recon/recon.jsp">
                </forward>
        </action>
        <action path="/recon/showProgress" 
type="com.sscims.palms.gui.recon.progress.ShowProgressAction" 
name="progressActionForm" scope="request" 
input="/pages/recon/progress/progress.jsp">
                <forward name="success" 
path="/pages/recon/progress/progress.jsp">              
                </forward>
        </action>
        <action path="/recon/showTMVDetails" 
type="com.sscims.palms.gui.recon.tmvdetails.ShowTMVDetailsAction" 
name="tmvDetailsActionForm" input="/pages/recon/tmvDetails/tmvDetails.jsp" 
scope="request" validate="false" >
                <forward name="success" 
path="/pages/recon/tmvDetails/tmvDetails.jsp">
                </forward>
        </action>
        <action path="/recon/showAnalysis" 
type="com.sscims.palms.gui.recon.analysis.ShowAnalysisAction" 
name="analysisActionForm">
                <forward name="success" 
path="/pages/recon/analysis/analysis.jsp">
                </forward>
        </action>
        <action path="/recon/showCash" 
type="com.sscims.palms.gui.recon.cash.ShowCashAction" name="cashActionForm" 
scope="request" input="/pages/recon/cash/cash.jsp">
                <forward name="success" path="/pages/recon/cash/cash.jsp">      
        
                </forward>        
        </action>
        <action path="/recon/showPosition" 
type="com.sscims.palms.gui.recon.position.ShowPositionsAction">
                <forward name="success" 
path="/pages/recon/position/position.jsp">              
                </forward>        
        </action>
        <action path="/recon/showChecklist" 
type="com.sscims.palms.gui.recon.checklist.ShowChecklistAction">
                <forward name="success" 
path="/pages/recon/checklist/checklist.jsp">            
                </forward>        
        </action>
        <action path="/recon/processTMVDetails" 
type="com.sscims.palms.gui.recon.tmvdetails.ProcessTMVDetailsAction" 
input="/pages/recon/tmvDetails.jsp" name="tmvDetailsActionForm" scope="request">
                <forward name="success" 
path="/pages/recon/tmvDetails/tmvDetails.jsp">
                </forward>
                <forward name="progress" path="/recon/showProgress.do">
                </forward>
        </action>
        <action path="/recon/processAnalysis" 
type="com.sscims.palms.gui.recon.analysis.ShowAnalysisAction" 
name="analysisActionForm">
                <forward name="success" 
path="/pages/recon/anlysis/analysis.jsp">
                </forward>
        </action>
        <action path="/defaultPageDispatcher" 
type="com.sscims.palms.gui.DefaultPageDispatcherAction">
                <forward name="recon_default" path="/recon/showWorkqueue.do" 
redirect="true">
                </forward>
        </action>
        <action path="/recon/reconDefaultPageDispatcher" 
type="com.sscims.palms.gui.recon.ReconDefaultPageDispatcherAction">
                <forward name="analysis" path="/recon/showAnalysis.do" 
redirect="true">
                </forward>
                <forward name="mktvalues" path="/recon/showTMVDetails.do" 
redirect="true">
                </forward>
                <forward name="progress" path="/recon/showProgress.do" 
redirect="true">
                </forward>
        </action>
        <action path="/testPA" type="com.sscims.palms.sample.PATestAction">
                <forward name="success" path="/pages/basicPage.jsp">
                </forward>
        </action>    
    </action-mappings>

<!-- ============================================= Controller Configuration -->
    <controller
       processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
       
    <!-- Message Resources -->
    <message-resources parameter="ApplicationResources" null="false"/>

<!-- =============================================== Plug Ins Configuration -->

  <!-- ======================================================= Tiles plugin -->
  <!--
     This plugin initialize Tiles definition factory. This later can takes some
     parameters explained here after. The plugin first read parameters from
     web.xml, thenoverload them with parameters defined here. All parameters
     are optional.
     The plugin should be declared in each struts-config file.
       - definitions-config: (optional)
            Specify configuration file names. There can be several comma
            separated file names (default: ?? )
       - moduleAware: (optional - struts1.1)
            Specify if the Tiles definition factory is module aware. If true
            (default), there will be one factory for each Struts module.
            If false, there will be one common factory for all module. In this
            later case, it is still needed to declare one plugin per module.
            The factory will be initialized with parameters found in the first
            initialized plugin (generally the one associated with the default
            module).
              true : One factory per module. (default)
              false : one single shared factory for all modules
       - definitions-parser-validate: (optional)
            Specify if xml parser should validate the Tiles configuration file.
              true : validate. DTD should be specified in file header (default)
              false : no validation

      Paths found in Tiles definitions are relative to the main context.
  -->

        <plug-in className="org.apache.struts.tiles.TilesPlugin" >
        <set-property property="definitions-config" 
value="/WEB-INF/tileDefinitions.xml"/>
        <set-property property="moduleAware" value="true" />
        <set-property property="definitions-parser-validate" value="true" />
        </plug-in>
  <!-- =================================================== Validator plugin -->

      <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, 
/WEB-INF/validation.xml"/>
      </plug-in>

</struts-config>

My ActionForm:

package com.sscims.palms.gui;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorActionForm;
import org.apache.struts.validator.ValidatorForm;

/**
 * Form bean for a Struts application.
 * @version     1.0
 * @author
 */
public class LoginActionForm extends ValidatorActionForm {

    private String username;
    private String password;
    
        /**
        * Constructor
        */
        public LoginActionForm() {

                super();

        }
        public void reset(ActionMapping mapping, HttpServletRequest request) {

                // Reset values are provided as samples only. Change as 
appropriate.

        }
        
        public ActionErrors validate(
                ActionMapping mapping,
                HttpServletRequest request) {

                
                ActionErrors errors = super.validate(mapping, request);
                if (errors == null) {
                        errors = new ActionErrors();
                }
                
                // Validate the fields in your form, adding
                // adding each error to this.errors as found, e.g.

                // if ((field == null) || (field.length() == 0)) {
                //   errors.add("field", new 
ActionError("error.field.required"));
                // }
                return errors;

        }
    
        /**
         * Returns the password.
         * @return String
         */
        public String getPassword() {
                return password;
        }

        /**
         * Returns the username.
         * @return String
         */
        public String getUsername() {
                return username;
        }

        /**
         * Sets the password.
         * @param password The password to set
         */
        public void setPassword(String password) {
                this.password = password;
        }

        /**
         * Sets the username.
         * @param username The username to set
         */
        public void setUsername(String username) {
                this.username = username;
        }

}

My validation.xml file:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules 
Configuration 1.1.3//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd";>

<form-validation>

    <global>

        <constant>
            <constant-name>postalCode</constant-name>
            <constant-value>^\d{5}\d*$</constant-value>
        </constant>

    </global>

    <formset>

        <!-- An example form -->
        <form name="/login">
            <field
                property="username"
                depends="required">
                    <arg key="login.username"/>
            </field>
            <field
                property="password"
                depends="required,mask">
                    <arg key="login.password"/>
                    <var>
                        <var-name>mask</var-name>
                        <var-value>^[0-9a-zA-Z]*$</var-value>
                    </var>
            </field>
        </form>

    </formset>

</form-validation>

Thanks in advance!
-Ben



[4/20/05 13:37:53:965 PDT] 63d4584b WebGroup      E SRVE0026E: [Servlet 
Error]-[action]: java.lang.IllegalArgumentException: Resources cannot be null.
        at org.apache.commons.validator.Validator.<init>(Validator.java:188)
        at 
org.apache.struts.validator.Resources.initValidator(Resources.java:299)
        at 
org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:106)
        at 
com.sscims.palms.gui.LoginActionForm.validate(LoginActionForm.java:40)
        at 
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:921)
        at 
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:206)
        at 
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at 
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
        at 
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
        at 
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
        at 
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
        at 
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
        at 
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
        at 
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
        at 
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
        at 
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
        at 
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
        at 
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
        at 
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
        at 
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
        at 
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
        at 
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
        at 
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
        at 
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
        at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to