When you have custom groups in your SharePoint solution, make sure that the master page gallery is either inheriting permissions from its parent to include the custom groups that you created (or manually add the required ones).It took me nearly a day to figure out why I get this kind of error when I was creating a custom (sub) site using a custom site definition with a contributor coming from my custom groups. The specified ChromeMasterUrl '/_catalogs/masterpage/BlueOcean.master' must be a server-relative url within site collection '/'. at Microsoft.SharePoint.Publishing.Internal.AreaProvisioner.SetLayoutRelatedProperties(PublishingWeb area, Boolean& updateRequired)
Basically, my custom contributor groups had no read access on the .master file which raised the exception stated above. Fixing the security on the master page gallery solved it.