The first claim is definitely wrong for 2007 as far as trading value, based on data in http://comtrade.un.org/pb/CommodityPages.aspx?y=2007.
The summary below (based on that URL) is quoted from an article by Mark Pendergrast "Coffee second only to oil? Is coffee really the second largest commodity? Mark Pendergrast investigates and finds some startling...".
Please note that the author is quite possible the original source of the meme/quote: In the introduction to "Uncommon Grounds: The History of Coffee and How It Transformed Our World (Basic Books, 1999)", he wrote: "Coffee is the second most valuable exported legal commodity on earth (after oil).". That book is listed as the main reference for the claim on Wikipedia, alongside the link to Mark's 2007 article refuting the claim.
Now, as far as his investigations in 2007:
The comparison with oil implies that we need to take into account not just agricultural products but other mineral commodities. This led me to the UN Comtrade website, which covers many different products (http://comtrade.un.org/pb/CommodityPa ges.aspx?y=2007). Sure enough, for the year 2007 (the latest available Comtrade tables), "petroleum oils and oils obtained from bituminous minerals, crude lead the pack at $1.09 trillion, while petroleum oils (non-crude) amount to $495 billion. Natural gas is $200 billion. Copper is $120 billion, not to mention an additional $38 billion listed under "copper ores and concentrates; copper mattes, copper cement." Aluminum is $116 billion, plus aluminum ores and concentrates for another $16.5 billion. Gold (non-monetary, excluding gold ores and concentrates) is $87 billion.
Eventually we get down to vegetable matter of one sort or another. The Comtrade list goes on and on. "Wheat (including spelt) and meslin, unmilled" accounts for $32.9 billion (but compare that with the FAO figure of $49.5 billion for wheat and flour in 2006). "Cotton fabrics, woven," yield $25.5 billion. Meat (not divided by type of animal) accounts for $43 billion, milk for another $31.6 billion and leather $23 billion. "Sugars, molasses and honey" draws $25 billion.
Finally, there is "coffee and coffee substitutes" for $22 billion. Subtract whatever chicory, barley and other faux coffees sell for, and you have a somewhat lesser figure for pure coffee. Not exactly number two in the world, by anyone's reckoning.