Upvote:3
Newark airport has many separate gate areas behind security. Depending which ones you're using, you may be able to take the United Airlines transfer shuttle to avoid leaving security. Otherwise, you may have to leave security to transfer from one to another.
The Newark Airport airlines list shows Aer Lingus at Terminal B and Air Canada at Terminal A. Fortunately, as ajd said, you'll preclear US immigration and customs in Dublin. So even if the transfer shuttle isn't an option, 2 hours would be enough to leave security in Terminal B, take the AirTrain to Terminal A, and clear security for the next flight.
Upvote:4
You will preclear US immigration and customs in Dublin, and your bags should be checked through, so all you have to do in Newark is walk from one plane to the other. Two hours should be plenty of time if your first flight is not delayed.