if I assume such a wavefunction which is an eigenvector of the momentum operator and plugging in the boundary conditions
"The boundary conditions" presumably means that the wavefunction goes to zero at the edges of the box. But if there are different boundary conditions, such as periodic boundary conditions, you should tell us...
I only get the trivial solution of the wavefunction being equal to 0. Am I going wrong somewhere ?
You are not wrong. When the boundary conditions are such that the wavefunction goes to zero at the edge, then there are no eigenstates of the momentum operator that satisfy the boundary conditions.
To put a little more color on this, you probably already know how to calculate eigenstates of the Hamiltonian, and you probably know they look like
$$
\phi_n = A\sin(\frac{n\pi x}{a})\;,
$$
for a box going from $0$ to $a$, where the boundary conditions are such that the wave function goes to zero at the edges.
In such a case you can see that the eigenfunction looks like two opposite traveling plane waves:
$$
\phi_n = \frac{A}{2i}(e^{i\frac{\pi n x}{L}}-e^{-i\frac{\pi n x}{L}})\;,
$$
which indicates to us that the momentum expectation value is probably zero. Indeed, the momentum expectation value is zero for all the Hamiltonian eigenstates since the eigenstates can be chosen to be real and thus:
$$
\bar p_n = \langle \phi_n| \hat p |\phi_n\rangle = -i\int_0^a dx \phi_n(x) \frac{d\phi_n}{dx}\;,
$$
and then, by integration by parts,
$$
=i\int_0^a dx \phi_n(x) \frac{d\phi_n}{dx} = -\bar p_n\;,
$$
and then, since we see that $\bar p = -\bar p$ we must have
$$
\bar p_n= 0
$$