Cavitation and shock wave formation in dense plasmas by relativistic electron beams