Did you check your linkage for your 4wd.
My buddy's 96 xj had the same problem and it turned out that the little mount for his linkage was broken. I was under the xj watching as he shifted to 4wd and it didn't move the little lever on the transfer case.
We went to the junkyard and got a new mount and installed it and it worked after that.