There are biogeochemical cycles for the building stones of the biomass (e.g. hydrogen, carbon, nitrogen, oxygen, etc...), so all of these atoms are recycled. To recycle them the organisms need energy, which they get from sunlight, from chemical materials, etc... (check microbial metabolism for further details).
Plants use sunlight as energy source, CO2 from air as carbon source, water and O2 from air as oxygen source, and so on... You can find more info about plant metabolism on wikipedia.