Like they said, the AW-4 is bulletproof. The tranny in the grands in one of their major weaknesses.
I would be more concerned with the axles, suspension, and rear brakes, probably the biggest weaknesses of the XJ. I had both axles rebuilt under warranty when I bought my '01 used, and I put a teraflex rear disc kit on. Now the axles are quiet and it stops as well as our subaru. I'm still not satisfied with the suspension, something is fairly loose. Supposedly the newest of the post '97's have soft bushings. I haven't dug into that one yet, I have some lift springs and new bushings ready to go into it, along with the coveted 242 t-case. Maybe the trackbar is loose. Now I just need the time.
The 4.0 and AW-4 are bulletproof even with sub-BITOG maintenance practices.
If I had to do it again I would look for a '98 or '99 with upcountry suspension and an NV-242 t-case, very rare but I think that's the sweet spot.