This is by using the older kernel for which the root works, then root the device and then flash back to the newer kernel. The download links for the Xperia Z can be found here and will work for handsets with both locked and unlocked bootloaders. It will also work for the Xperia ZL and Xperia ZR but you will need to download the appropriate kernel.
Thanks @DooMLoRD_XDA!