Magnetic energy due to a line current

I am trying find the magnetic energy due to a straight line current at the centre of a cylindrical container of radius $$R$$. If I use the formula $$U_{B}=\frac{1}{2\mu_0}\int_{V} B^2 d{\tau}$$ in the region $$(r_c\leq \rho\leq R)$$, since $$\vec{B}=\frac{\mu_0 I}{2\pi \rho}\hat{\phi}$$ immediately I can find that the magnetic energy per unit length is $$\frac{U_{B}}{L}=\frac{\mu_0 I^2}{4\pi}\ln\left(\frac{R}{r_c}\right)$$ But if I make use of the vector potential and write $$U_{B}=\frac{1}{2}\int_{V}\vec{J}\cdot\vec{A}\ d{\tau}-\frac{1}{2\mu_0}\oint_{\partial V}\vec{B}\times \vec{A}\cdot d\vec{a}$$ Clearly the first integral vanishes because there is no current in the region $$(r_c\leq \rho\leq R)$$. Therefore, $$U_{B}=-\frac{1}{2\mu_0}\oint_{\partial V}\vec{B}\times \vec{A}\cdot d\vec{a}$$ Choose the Coulomb gauge $$\nabla\cdot\vec{A}=0$$, then it can be found that $$\vec{A}=-\frac{\mu_0 I}{2\pi}\hat{z}\ln{\rho}$$ Therefore, $$-\vec{B}\times\vec{A}\cdot d{\vec{a}}$$ is just $$BA\ d{a}$$ and hence $$\frac{U_{B}}{L}=\frac{1}{2\mu_0}\int_{0}^{2\pi}\left(\frac{\mu_0 I}{2\pi\rho}\right)\left(\frac{\mu_0 I}{2\pi}\ln\rho\right)\rho d{\theta}$$ which do gives the same result. The problem is that if I add some arbitrary constant to the vector potential, the magnetic field is still the same and thus it is expected that the energy is the same. But in the above integral, adding some constant vector $$-\lambda\hat{z}$$ to the vector potential will gives an extra term $$\frac{U_{B}}{L}=\frac{1}{2}I\lambda$$ which does not make any sense. What did I do wrong?