screw/glue a filler panel to the cavity sliding wall
screw upper to the filler panel and the cabinetry on the other side
its no different to how alot of cabinets are installed above fridges to give some air space for the how air to go past. cabinets are normally about 100mm or so "shallower" then the rest and the hot air from the fridge can escape up the back of it.
in this instantance its just the side screws that take the weight, instead of the side and rear screws, but unless you're storing your dumbell set above it I don't think it'll be an issue