Struts (can’t find validator-rules.xml after editing)

Recently I wrote some classes to extend the Struts validation framework(Struts 1.3.8). I edited the validator-rules.xml file and, as I’m used to do, I pressed ctrl+shift+f in Eclipse. Which means format the document.

The next logical step was. Run and test. Oh noooooooo’s !!!!! What happened? No validation happening at all.

Unbelievable or not but Struts could not find any validator-rules.xml . Maybe a little error in the validator-rules file? ( The first logic reaction). Validate & Check conclusion nothing wrong. Recheck the classes for errors: conclusion, nothing wrong. ( I knew that before I checked it! But…. good practice to check again). Removed anything I wrote into the validator-rules to restore it in original state -> no result.

Next step: search the internet for similar errors:
Nice results! Forums and mailing archives telling me a lot of stuff I could do.

  • remove the commons-validator.jar and attach a fresh one from a struts blank application.
  • remove the xml files that have anything to do with validator framework.
  • copy the DTD of validator-rules.xml to your web-inf directory and take the DTD from there.

and so on. I read on for a couple hours but nothing came up with a solution. I was getting really agitated but what could I do besides sit back and pain my brain?

When my brain was almost at cooking point, I decided to start from scratch again. And try copying my extended validator-rules file and class files to a new blank struts application [fun 🙁 ].

Guess what?… same result.

Eventually (2 days later, no I did not search 2 days, it was just a busy weekend) I noticed a difference between my edited file and the original. The DOCTYPE tag in my edited file was written on 1 line, in the original it is spread over 3 lines. Yes, yes, that was the evildoer. A stupid DTD tag written in one line screwed up the whole thing.

THANK YOU ctrl+shift+f !!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.