What's the number on the ejector? Is it 336 or 30274?(9mm)
Some recent production Gen3/4 9/40/357 eject erratically. Sometimes it's caused by the extractor not moving freely enough, it's simple enough to replace it if that's the case. With some however, something else is causing it because using an older extractor known to work properly in another Glock makes no difference. My Gen3 G27 had the problem and using the extractor from my Gen3 G23 which ejects fine made no difference. When I compared how each slide held the extractor from my G23, the claw sat noticeably further forward in the G27 slide both with and without the rim of a spent casing under the claw, and the spent casing was held to the breech face with noticeably less tension. In the case of my G27, I believe the cut-out in the slide which holds the extractor was not positioned correctly. I installed a 28926(.40) ejector into the Gen3 trigger housing for this gun and replaced the extractor with an older extractor and that fixed the problem.
The solution to the problem can vary quite a bit from one gun to another. For some, simply replacing the extractor fixes it. For others, the new ejector is required(pictured above). For some, both are required. And for a rare few, they actually have to use a .40 extractor in their 9mm slide to fix the ejection. The .40 extractor claw sits closer to the breech face to more firmly hold the rim, and has a 5 degree rearward tilt to the claw to help raise the case mouth of the spent casing higher during ejection so that it better clears the bottom of the ejection port. In most cases of erratic ejection in a 9mm slide, the .40 extractor drops right in, it functions fine and fixes the ejection problem. In one case the guy had to file down the very top portion of the claw that sits closest to the breech face because the rounds wouldn't feed until a certain amount was filed down. Once he filed it down to the right point, it functioned and ejected perfectly.
Here's a picture showing the difference between 9mm and .40 extractor claws. On top is 9mm, note the parallel claw. On bottom is .40, note the tilt to the claw. The very top of the .40 claw is what had to be filed down in one case to make it work properly in a 9mm Glock.
http://i153.photobucket.com/albums/s207/atp9697/extractor.jpg
Edit: As firesupport says below, almost every single case I've heard of erratic ejection in a .45ACP Glock has been fixed by replacing the extractor.