Mendix recommends to upgrade first to the highest 4 version and then to the latest version of 5.21.5 and not the 5.18 since they have added some conversion bug fixes in the higher versions.
Otherwise, I would recommend to clean you deployment directory after upgrading. This may help solve the problem.
If this does not help, you could deploy to eclipse and check for errors of deprecated functions in your java code.
last thing is to start updating all the widget you use and and stuff like the community commons if you use that.