Given that the BVP is a second-order inhomogeneous ODE, we find the characteristic equation to be in the form $$r^2+a^2=0\implies r=\pm ai.$$
Thus, the homogeneous equation is $$u_h=C_1\cos(ax)+C_2\sin(ax).$$
The particular equation is $$u_p=C_3x\sin(\pi x)+C_4x\cos(\pi x),$$ $$u_p'=-C_3\pi x\cos(\pi x)+C_3\sin(\pi x)-C_4\pi x\sin(\pi x)+C_4\cos(\pi x),$$ $$u_p''=-C_3\pi^2 x\sin(\pi x)+2C_3\pi\cos(\pi x)-2C_4\pi\sin(\pi x)-C_4\pi^2 x\cos(\pi x).$$
Substituting for the given ODE, we have $$-C_3\pi^2 x\sin(\pi x)+2C_3\pi\cos(\pi x)-2C_4\sin(\pi x)-C_4\pi^2 x\cos(\pi x)+\pi^2(C_3x\sin(\pi x)+C_4x\cos(\pi x))=\sin(\pi x),$$
and we get $C_3=0$ and $C_4=-\frac{1}{2\pi}$. Then the general solution is now, $$u=u_h+u_p=C_1\cos(ax)+C_2\sin(ax)-\frac{1}{2\pi}x\cos(\pi x)$$
Using the initial conditions, we get $C_1=1$ and $C_2=\frac{-2-\frac{1}{2\pi}-\cos(a)}{\sin(a)}$, but $a=\pm\pi$ and so $\sin(\pm\pi)=0$, which indicates $u$ is undefined when $a=\pm\pi$. But is it truly undefined? I am not sure I solved this correctly.