This paper considers the problem of beamforming optimization in a cognitive cooperative energy harvesting net- work, in which the secondary transmitter (ST) harvests energy from the primary transmitter (PT) and relays the information for the primary user (PU) with amplify-and-forward (AF) relay protocol. When the channel of the primary system is affected with deep fading or shadowing effects, the ST can assist the primary information transmission. It is particularly useful to employ the energy harvesting protocol to avoid that the ST does not have enough energy to assist the PU. Based on the self-energy recycling relay protocol, we study the beamforming optimization problem. We develop a semidefinite programming (SDP) relaxation method to solve the proposed problem. We also use SDP and one-dimension (1-D) optimization to solve the beamforming optimization based on a time-switching relaying protocol (TSR) as a benchmark. The simulation results are presented to verify that the self-energy recycling protocol achieves a significant rate gain compared to the TSR protocol and the power-splitting relaying (PSR) protocol.