something is not right in your database if it is trying to run the script version 2.2.1.9
make sure in the mp_SchemaVersion table the row for mojoportal-core has version 2.3.9.7
if an unhandled error happens it checks that table to determine if it needs to run upgrade scripts and if it does it redirects to the setup page.
it should never run any script older than the current version