Believe it or not, somebody may have to tap on a rod to get the cartridge out, but there are things you can do to make it much safer.
First, you likely have a sperated case with the front half still in the chamber. The next round is wedged into the remaining space. Set the upper on its muzzle. If the ammo does not have a sealed primer, WD40 on the primer will help to desensitize the primer, but a couple drops of household bleach will try to deactivate it completely. While the primer is being deactivated by a few drops of bleach, run Kroil, Hoppes, whatever, into the chamber-cartridge interface. You are trying to loosen any grip between the fresh cartridge and the chamber and the seperated case (if there is one in there).
After that sits overnight, you can probably tap on the case head with a little punch and it will drop out. If not, the industry has some methods for handling these problems when they came up with. You MAY want to just take it to a trusted gunsmith. This is a high stress thing to experience.
The precautions are:
Block the upper to a table, ejection port down. Clamp wooden blocks to the table to corral the rifle or maybe clamp the rifle itself using wooden blocks;
Gloves and safety glasses;
No one beind the upper or exposed to the open bottom of the upper (if the cartridge fires, it will burst and throw fragments);
Stand on the closed side of the upper - expose none of your body to the muzzle of openings in the upper;
Slide a rod with no accessory into the barrel - do not place a hand or any other body part over the end of the rod;
Place a piece plywood between you and rifle to shield you;
Tap on the rod with a dead blow or mallet.
If this sounds risky to you, it does still carry some risk. I would do it, but I was a trained professional in the industry. You MAY want to just take the upper to a trusted gunsmith. That's twice I have made that suggestion...