A New Jersey judge has dismissed a lawsuit brought by the state against ExxonMobil and other major oil companies, ruling that the claims need to be decided in federal court.