Solving for Pareto Efficient Utility Possibility Frontier using constrained optimisation
The first constraint you have, $U_2(x_2)=x_2$, is not really a constraint. 

Since points on the UPF is Pareto optimal, you should instead have $U_2(x_2)\ge \bar u$ or $x_2\ge \bar u$ as a constraint, where $\bar u$ is some arbitrary level of utility for individual 2 on the UPF. In other words, given that we're keeping individual 2's utility to be no lower than $\bar u$, how best can we make individual 1's utility as high as possible with the available resources.