You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shale.apache.org by "ankit kakkar (JIRA)" <ji...@apache.org> on 2008/01/04 12:32:04 UTC
[jira] Created: (SHALE-481) Nullpointer exception when validator
resources loaded from the custom configuration file in 1.0.4
Nullpointer exception when validator resources loaded from the custom configuration file in 1.0.4
-------------------------------------------------------------------------------------------------
Key: SHALE-481
URL: https://issues.apache.org/struts/browse/SHALE-481
Project: Shale
Issue Type: Bug
Components: Validator
Affects Versions: 1.0.4
Environment: Windows Xp Sp2, Jdk 1.5, Tomcat 5.5, shale 1.0.4
Reporter: ankit kakkar
The server is throwing nullpointer exception whenever it tries to load rules from custom rule xml file.
java.lang.NullPointerException
at org.apache.shale.validator.CommonsValidator.getValidatorAction(CommonsValidator.java:730)
at org.apache.shale.validator.faces.ValidatorScript.writeValidationFunctions(ValidatorScript.java:424)
at org.apache.shale.validator.faces.ValidatorScript.encodeBegin(ValidatorScript.java:652)
at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:584)
at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:471)
at org.apache.jsp.greeting_jsp._jspx_meth_s_005fvalidatorScript_005f0(greeting_jsp.java:319)
at org.apache.jsp.greeting_jsp._jspx_meth_h_005fform_005f0(greeting_jsp.java:173)
at org.apache.jsp.greeting_jsp._jspx_meth_f_005fview_005f0(greeting_jsp.java:115)
at org.apache.jsp.greeting_jsp._jspService(greeting_jsp.java:80)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
at org.apache.shale.validator.faces.ValidatorViewHandler.renderView(ValidatorViewHandler.java:130)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)
Jan 4, 2008 4:53:50 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
When I analyzed this issue, I found that there is a bit of code missing which was handling the null case and was loading the customer validation xml file from the web.xml of the application.
I am pasting the relevent function from the latest version ie 1.0.4
package org.apache.shale.validator;
/**
* <p>Return the validator resources that were configured and cached
* at application startup time.</p>
*/
private static ValidatorResources getValidatorResources() {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext external = context.getExternalContext();
Map applicationMap = external.getApplicationMap();
return (ValidatorResources) applicationMap.get(Globals.VALIDATOR_RESOURCES);
}
Now I am pasting the same function from the previous version. I noticed this on the http://shale.apache.org/shale-core/xref/org/apache/shale/validator/CommonsValidator.html url.
/***
461 * This method lazily configures validator resources by reading either
462 * the default <code>validalidator-rules.xml</code> file in
463 * shale-core.jar or the list of resources configured using the init
464 * param <code>org.apache.shale.validator.VALIDATOR_RULES</code>.
465 *
466 * @return validator resources loaded from the configuration file.
467 */
468 private static ValidatorResources getValidatorResources() {
469 final String VALIDATOR_RESOURCES_KEY =
470 "org.apache.shale.validator.resources";
471 FacesContext context = FacesContext.getCurrentInstance();
472 ExternalContext external = context.getExternalContext();
473 Map applicationMap = external.getApplicationMap();
474 ValidatorResources validatorResources
475 = (ValidatorResources) applicationMap.get(VALIDATOR_RESOURCES_KEY);
476 if (validatorResources == null) {
477 try {
478 String pathnames = external.getInitParameter(Globals.VALIDATOR_RULES);
479 if (pathnames == null || pathnames.length() <= 0) {
480 pathnames = Globals.DEFAULT_VALIDATOR_RULES;
481 }
482 StringTokenizer st = new StringTokenizer(pathnames, ",");
483 List urlList = new ArrayList();
484 while (st.hasMoreTokens()) {
485 String validatorRules = st.nextToken().trim();
486 logger.log(Level.INFO,
487 messages.getMessage("commonsValidator.loadresource",
488 new Object[] {validatorRules}));
489 URL input = external.getResource(validatorRules);
490 if (input == null) {
491 input = CommonsValidator.class.getResource(validatorRules);
492 }
493 if (input != null) {
494 urlList.add(input);
495 } else {
496 logger.log(Level.WARNING,
497 messages.getMessage("commonsValidator.skipresource",
498 new Object[] {validatorRules}));
499 }
500 }
501 int urlSize = urlList.size();
502 String[] urlArray = new String[urlSize];
503 for (int urlIndex = 0; urlIndex < urlSize; urlIndex++) {
504 URL url = (URL) urlList.get(urlIndex);
505 urlArray[urlIndex] = url.toExternalForm();
506 }
507 validatorResources = new ValidatorResources(urlArray);
508 applicationMap.put(VALIDATOR_RESOURCES_KEY, validatorResources);
509 } catch (IOException ex) {
510 logger.log(Level.SEVERE, messages.getMessage("commonsValidator.loaderror"), ex);
511 return null;
512 } catch (SAXException ex) {
513 logger.log(Level.SEVERE, messages.getMessage("commonsValidator.loaderror"), ex);
514 return null;
515 }
516 }
517
518 return validatorResources;
519 }
You yourself can see here that validatorResources is checked for null in the second case but it has been returned directly from the latest version implementation.
Pls look into the same asap and if now there is some alternate way of doing this thing, then do let me know.
thanks and regards,
ankit kakkar
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (SHALE-481) Nullpointer exception when validator
resources loaded from the custom configuration file in 1.0.4
Posted by "ankit kakkar (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/SHALE-481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ankit kakkar updated SHALE-481:
-------------------------------
Priority: Blocker (was: Major)
Its been a blocker as I am not able to load my custom validation file and thus can't move forward with shale validators
> Nullpointer exception when validator resources loaded from the custom configuration file in 1.0.4
> -------------------------------------------------------------------------------------------------
>
> Key: SHALE-481
> URL: https://issues.apache.org/struts/browse/SHALE-481
> Project: Shale
> Issue Type: Bug
> Components: Validator
> Affects Versions: 1.0.4
> Environment: Windows Xp Sp2, Jdk 1.5, Tomcat 5.5, shale 1.0.4
> Reporter: ankit kakkar
> Priority: Blocker
>
> The server is throwing nullpointer exception whenever it tries to load rules from custom rule xml file.
> java.lang.NullPointerException
> at org.apache.shale.validator.CommonsValidator.getValidatorAction(CommonsValidator.java:730)
> at org.apache.shale.validator.faces.ValidatorScript.writeValidationFunctions(ValidatorScript.java:424)
> at org.apache.shale.validator.faces.ValidatorScript.encodeBegin(ValidatorScript.java:652)
> at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:584)
> at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:471)
> at org.apache.jsp.greeting_jsp._jspx_meth_s_005fvalidatorScript_005f0(greeting_jsp.java:319)
> at org.apache.jsp.greeting_jsp._jspx_meth_h_005fform_005f0(greeting_jsp.java:173)
> at org.apache.jsp.greeting_jsp._jspx_meth_f_005fview_005f0(greeting_jsp.java:115)
> at org.apache.jsp.greeting_jsp._jspService(greeting_jsp.java:80)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
> at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
> at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
> at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
> at org.apache.shale.validator.faces.ValidatorViewHandler.renderView(ValidatorViewHandler.java:130)
> at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
> at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
> at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
> at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
> at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
> at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
> at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
> at java.lang.Thread.run(Thread.java:595)
> Jan 4, 2008 4:53:50 PM org.apache.catalina.core.StandardWrapperValve invoke
> SEVERE: Servlet.service() for servlet Faces Servlet threw exception
> When I analyzed this issue, I found that there is a bit of code missing which was handling the null case and was loading the customer validation xml file from the web.xml of the application.
> I am pasting the relevent function from the latest version ie 1.0.4
> package org.apache.shale.validator;
> /**
> * <p>Return the validator resources that were configured and cached
> * at application startup time.</p>
> */
> private static ValidatorResources getValidatorResources() {
> FacesContext context = FacesContext.getCurrentInstance();
> ExternalContext external = context.getExternalContext();
> Map applicationMap = external.getApplicationMap();
> return (ValidatorResources) applicationMap.get(Globals.VALIDATOR_RESOURCES);
> }
> Now I am pasting the same function from the previous version. I noticed this on the http://shale.apache.org/shale-core/xref/org/apache/shale/validator/CommonsValidator.html url.
> /***
> 461 * This method lazily configures validator resources by reading either
> 462 * the default <code>validalidator-rules.xml</code> file in
> 463 * shale-core.jar or the list of resources configured using the init
> 464 * param <code>org.apache.shale.validator.VALIDATOR_RULES</code>.
> 465 *
> 466 * @return validator resources loaded from the configuration file.
> 467 */
> 468 private static ValidatorResources getValidatorResources() {
> 469 final String VALIDATOR_RESOURCES_KEY =
> 470 "org.apache.shale.validator.resources";
> 471 FacesContext context = FacesContext.getCurrentInstance();
> 472 ExternalContext external = context.getExternalContext();
> 473 Map applicationMap = external.getApplicationMap();
> 474 ValidatorResources validatorResources
> 475 = (ValidatorResources) applicationMap.get(VALIDATOR_RESOURCES_KEY);
> 476 if (validatorResources == null) {
> 477 try {
> 478 String pathnames = external.getInitParameter(Globals.VALIDATOR_RULES);
> 479 if (pathnames == null || pathnames.length() <= 0) {
> 480 pathnames = Globals.DEFAULT_VALIDATOR_RULES;
> 481 }
> 482 StringTokenizer st = new StringTokenizer(pathnames, ",");
> 483 List urlList = new ArrayList();
> 484 while (st.hasMoreTokens()) {
> 485 String validatorRules = st.nextToken().trim();
> 486 logger.log(Level.INFO,
> 487 messages.getMessage("commonsValidator.loadresource",
> 488 new Object[] {validatorRules}));
> 489 URL input = external.getResource(validatorRules);
> 490 if (input == null) {
> 491 input = CommonsValidator.class.getResource(validatorRules);
> 492 }
> 493 if (input != null) {
> 494 urlList.add(input);
> 495 } else {
> 496 logger.log(Level.WARNING,
> 497 messages.getMessage("commonsValidator.skipresource",
> 498 new Object[] {validatorRules}));
> 499 }
> 500 }
> 501 int urlSize = urlList.size();
> 502 String[] urlArray = new String[urlSize];
> 503 for (int urlIndex = 0; urlIndex < urlSize; urlIndex++) {
> 504 URL url = (URL) urlList.get(urlIndex);
> 505 urlArray[urlIndex] = url.toExternalForm();
> 506 }
> 507 validatorResources = new ValidatorResources(urlArray);
> 508 applicationMap.put(VALIDATOR_RESOURCES_KEY, validatorResources);
> 509 } catch (IOException ex) {
> 510 logger.log(Level.SEVERE, messages.getMessage("commonsValidator.loaderror"), ex);
> 511 return null;
> 512 } catch (SAXException ex) {
> 513 logger.log(Level.SEVERE, messages.getMessage("commonsValidator.loaderror"), ex);
> 514 return null;
> 515 }
> 516 }
> 517
> 518 return validatorResources;
> 519 }
> You yourself can see here that validatorResources is checked for null in the second case but it has been returned directly from the latest version implementation.
> Pls look into the same asap and if now there is some alternate way of doing this thing, then do let me know.
> thanks and regards,
> ankit kakkar
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.