Typically , a tune up will cure this issue . Plugs , wires , cap and rotor .
Occasionally , a weak coil can do it . Bad grounds might make the coil signal weak also . Check and clean connections
Fuel pressure should be tested with a gauge , and can cause the issue if not right
Bad or poor signal from the crank position sensor (CPS)
Check wires around exhaust for any shorts
Lastly , valve springs . 97-98 apparently saw a batch of weak springs . Jeep has a TSB to address that problem which is nothing more than replacing the valve springs and cleaning the carbon that typically builds up from this problem out the combustion chambers causing the mis-fires .
Attempt a good misting with a water hose while the engine is running . See if it starts running rough . Good ignition systems can handle a little water with no effect
Disconnect the battery , clear the codes . Give 30 mins disconnected to be certain it's cleared . As soon as the jeep tosses a check engine light , check the codes ASAP , report results here .