When you have a power of x, say power n, you will typically to try a polynomial of degree n including lower power terms.
Use (Ax+ B)cos(x)+ (Cx+ D)sin(x).
Then y'= A cos(x)- (Ax+ B) sin(x)+ C sin(x)+ (Cx+ D) cos(x)= (Cx+ A+ D)cos(x)- (Ax+ B- C)sin(x)
and y''= -2A sin(x)- (Ax+ B) cos(x)+ 2C cos(x)- (Cx+ D) sin(x)= (Cx+ D- 2A)sin(x)- (Ax+ B- 2C)cos(x)
So y''+ 4y= (Cx- Ax+ D- 2A- B+ C)sin(x)+ (Cx- Ax+ A+ D- B+ 2C)cos(x)
We want that to be equal to 4x sin(x). We want C- A= 4 , D- 2A- B+ C= 0, C- A= 0, A+ D- B+ 2C= 0, four equations to solve for A, B, C, and D.