The document library edit does not work when the context is changed and on using a JCR hook.
The problem happens because CMD is going as empty string to the edit file action.
On looking at edit_file_entry.jsp i found the hidden variable CMD in the form is not instantiated to anything. So i put a default value for it "Update".
If i use this logic it fails at the JCRHook. The class DLFileEntryLocalService tries to delete the version of file if it already exists and if the version does not exist it catches NoSuchFileException and ignores it. The problem is JCRHook was throwing back SystemException and not NoSuchFileException and hence the code was failing. I changed JCRHook to throw back NoSuchFileException and it works.
Please refer the patch i have attached