File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Cannot load a validator resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cannot load a validator resource" Watch "Cannot load a validator resource" New topic
Author

Cannot load a validator resource

Namrta Pandey
Ranch Hand

Joined: Jul 22, 2008
Posts: 36
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

Joined: Sep 29, 2008
Posts: 12617

Do both those files exist in your /WEB-INF?
Namrta Pandey
Ranch Hand

Joined: Jul 22, 2008
Posts: 36
yes, both validation.xml and validator-rules.xml are under WEB-INF folder.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jul 22, 2008
Posts: 36
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jul 22, 2008
Posts: 36
following are the configuration of action and form in struts-config.xml :

form:



action:


Thanks.
Namrta Pandey
Ranch Hand

Joined: Jul 22, 2008
Posts: 36
no reply ....
Namrta Pandey
Ranch Hand

Joined: Jul 22, 2008
Posts: 36
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

Joined: Jul 22, 2008
Posts: 36
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.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot load a validator resource