Josephson phase transition influenced by the presence of quantum impurities in the superconductors