Upgrade Oracle APEX 4.0.2 to 5.1.1 error
This is

Bug 25560625 : ORA-24344 ERRORS IN INSTALL.LOG THROUGH UPGRADE FROM APEX 4.0.2 TO 5.1

Still under investigation.

You could upgrade to 4.1 and then to 5.1 to avoid this bug, or you could also try 5.0.