is this happening with a round in the chamber or empty? By locking, Do you mean that the slide will not go all the way forward? Or is the slide going all the way forward but just not locking up? There could be an issue with the barrel not seating all the way into the receiver. There could also be an issue withthe locking lug or the barrel extension lug recess. I would need a lot more info to get you in the right direction.
There could also be an issue with the trigger group and the slide release not functioning correctly. is the slide release dropping down where it belongs and can be pushed up to the release position or is it stuck in the release position? A good cleaning on th etrigger group could solve your issue. HOT soapy water and fast agitation in the water then blow it out with compressed air and lightly oil all parts. or spray it out real good with non-clorinated brake cleaner and oil.
CPL holder since 1991, NRA Lifetime Member, DU Member, NICET certified
"For those who would give up essential liberty to purchase a little temporary safety, deserve neither Liberty nor safety.—Ben Franklin.”