This is

[**Bug 25560625 : ORA-24344 ERRORS IN INSTALL.LOG THROUGH UPGRADE FROM APEX 4.0.2 TO 5.1**][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.

  [1]: https://support.oracle.com/epmos/faces/BugDisplay?_adf.ctrl-state=1bnqbvdcyb_363&id=25560625