Ok, now that I've gotten past super.init(config), onto the validator not working. I get the following error:
[java] 2003-05-30 14:12:43,734 ERROR [Ajp13Processor[8009][0]] Validator.validateFieldForRule(4 61) | reflection: null [java] java.lang.reflect.InvocationTargetException [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java :25) [java] at java.lang.reflect.Method.invoke(Method.java:324) [java] at org.apache.commons.validator.Validator.validateFieldForRule(Validator.java:4 54) [java] at org.apache.commons.validator.Validator.validateField(Validator.java:544) [java] at org.apache.commons.validator.Validator.validate(Validator.java:582) [java] at com.comcast.cable.dmc.itd.cct.webapp.action.RegistrationServlet.execute(Regi strat ionServlet.java:146) >From the following code: ValidatorResources resources = new ValidatorResources(); InputStream rules = getServletContext().getResourceAsStream("/WEB-INF/validator-rules.xml"); ValidatorResourcesInitializer.initialize(resources, rules); InputStream custom = getServletContext().getResourceAsStream("/WEB-INF/validator-rules-custom.xml "); ValidatorResourcesInitializer.initialize(resources, custom); InputStream forms = getServletContext().getResourceAsStream("/WEB-INF/validation.xml"); ValidatorResourcesInitializer.initialize(resources, forms); // Create a validator with the userForm Validator validator = new Validator(resources, "userFormEx"); // Tell the validator which bean to validate against. validator.addResource(Validator.BEAN_KEY, userForm); // Validate the checkoutForm object and store the validation results try { // Execute the validation rules 146: ValidatorResults results = validator.validate(); <<-- Error occurs here if (log.isDebugEnabled()) { log.debug(results.getResultValueMap()); } } catch (ValidatorException ex) { // Log the validation exception log.warn("A validation exception occurred", ex); } The validator is working fine in my Action classes, just not outside. I'm trying to use it in a servlet that's not an Action because all my actions (/do/*) are protected by form-based authentication. This servlet is used for users to self-register. If anyone has an elegant solutions to self-register (not using a servlet), let me know. Thanks, Matt -----Original Message----- From: Raible, Matt Sent: Friday, May 30, 2003 7:13 AM To: '[EMAIL PROTECTED]' Subject: Using the Validator outside of Struts I'm trying to use the Validator to validate that a user has entered their information in a self-registration servlet. However, I'm getting a NullPointerException at the following line when running a test using Cactus: InputStream rules = getServletContext().getResourceAsStream("/WEB-INF/validator-rules.xml"); Error: [junit] java.lang.NullPointerException [junit] at javax.servlet.GenericServlet.getServletContext()Ljavax.servlet.ServletContex t;(Ge nericServlet.java:204) [junit] at com.comcast.cable.dmc.itd.cct.webapp.action.RegistrationServlet.execute(Ljav ax.se rvlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(Reg istrationServlet.java:12 2) Full code: ValidatorResources resources = new ValidatorResources(); InputStream rules = getServletContext().getResourceAsStream("/WEB-INF/validator-rules.xml"); ValidatorResourcesInitializer.initialize(resources, rules); InputStream forms = getServletContext().getResourceAsStream("/WEB-INF/validation.xml"); ValidatorResourcesInitializer.initialize(resources, forms); // Create a validator with the userForm Validator validator = new Validator(resources, "userFormEx"); // Tell the validator which bean to validate against. validator.addResource(Validator.BEAN_KEY, userForm); // Validate the checkoutForm object and store the validation results try { // Execute the validation rules ValidatorResults results = validator.validate(); if (log.isDebugEnabled()) { log.debug(results.getResultValueMap()); } } catch (ValidatorException ex) { // Log the validation exception log.warn("A validation exception occurred", ex); } Any help is appreciated. Thanks, Matt --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]