Meaningful Error Messages #24

Having just managed to discover the cause of a particular error message, I thought I’d share the solution with the community.

Once in while you come across error messages that point you in absolutely no direction at all. Most recently I’ve been receiving ‘Failed validation: ApexPage‘. Thinking that I might get something more meaningful from the in-browser IDE I dumped my code there and got this little gem

ErrorError: common.request.servlet.PageDispatcher$Hack404
ErrorError: null
Considering that I was working with a several hundred line file, this made me less than happy. At times like these I whip out that old faithful tool of developer’s everywhere, theĀ binary search algorithm. Using good ol’ BSA I remove half my source code at a time, save and attempt to compile. If the error message disappears I know which half of my code contains the error. Partition that half into further halves and continue until resolved.
Using this advanced technique I discovered that the source code in my packaging Org was being altered. More specifically $Page page references within VisualForce pages are prepended with my package namespace. But only some of the time(A bug that I’ve heard should be fixed soon) e.g. If I were coding in Eclipse and my page contained the following code,
<apex:outputLink value=”{!URLFOR($Page.MyPage)}”>…
And I were to ‘Save to Server’ using my packaging Org credentials, the code would then read,
<apex:outputLink value=”{!URLFOR($Page.MyPackage__MyPage)}”>…
Where MyPackage is my package namespace.
The problem isn’t immediately obvious as I would not receive an error message. In fact everything would be hunkydory until I committed this change into my repository, and other developers who aren’t working with my packaging Org check the code out. When they try to deploy they get the above error. The solution is quite simple though, remove the namespace prefix from the code and Bob’s your uncle.
Failed validation: ApexPag

Leave a Comment