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]