Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot load a validator resource

 
Namrta Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to struts (1.2) and facing problem in applying validator framework. When I am adding :

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

to my struts-config.xml and starting Tomcat server, it is giving me following error:

INFO: Marking servlet action as unavailable
Jun 18, 2009 12:07:54 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /ParvatiHandicraft threw load() exception
javax.servlet.UnavailableException: Cannot load a validator resource from '/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml'
at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:172)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1105)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Unknown Source)

My project was missing commons-validator.jar so I downloaded it and put it in my application, but still I'm facing the same problem.
Please help me, as without solving this I cannot move forward in my project.

Thanks in Advance.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do both those files exist in your /WEB-INF?
 
Namrta Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, both validation.xml and validator-rules.xml are under WEB-INF folder.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are they valid? I'm a little skeptical they're being deployed; have you checked the physical deployment directory? Are the filenames spelled correctly?
 
Namrta Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David, it was some problem with DTD specification in validation.xml. But now page is coming fine but it is not validating the fields. For example in a textbox i have applied required validation, but it is going to the action without showing any message even if i am not entering any values.

This is my form :

login.jsp



validation.xml


Please tell me where I am going wrong.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags; without them it's difficult to read code and configuration.

We'll also need to see the configuration for both the action and form bean.
 
Namrta Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
following are the configuration of action and form in struts-config.xml :

form:



action:


Thanks.
 
Namrta Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no reply ....
 
Namrta Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I have resolved the problem.
I removed validate method from my form bean.
after doing this validation messages were displaying like this:

Then I replaced

from validator.xml by

and it worked.
Though it worked, I don't know the reason of removing validate method from my form bean, If anybody has any idea please guide me.
Also now as it is working with validation.xml but while showing ActionMessages in JSP, it is printing the meassage with ???en_US.... :
In my action class :

My JSP when i tried this :

It didn't work, as in it was not showing me any error message so i replaced it with :

Now it's printing the error message like :

Please help me to solve this problem. And also let me know why <bean:messages...> is not working.

Thanks in advance.
Namrta
 
Namrta Pandey
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ignore the second problem, I've resolved this.
Its just that while adding messages to actionmessages i add second argument i.e. for resource bundle false.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic