The Silver Lining

Lessons & Learnings from a salesforce certified technical architect.

Meaningful Error Messages #24

leave a comment »

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

Error Error: common.request.servlet.PageDispatcher$Hack404
Error Error: 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
Advertisements

Written by Wes

July 14, 2009 at 11:51 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: