American food companies Campbell Soup and Hershey have egg on their faces after recent acquisitions.

Both companies, with highly profitable but slow-growing core products, have charged off hundreds of millions of dollars as much-touted food deals failed to pan out.

Campbell's purchase of Bolthouse Farms and Garden Fresh Gourmet, in 2012 and 2015, pushed the Camden canned-soup and baked-goods company into the fresh-food aisles of supermarkets. But the integration has not always gone smoothly.

Meanwhile, the Hershey Co., a laggard in global chocolate sales for decades, made a big play for China with its purchase of Shanghai Golden Monkey, a candy and protein-based bean snacks company. But its hopes crashed as the acquisition transformed itself into a monkey on Pennsylvania-based Hershey's financial ledgers.

The No. 1 U.S. chocolate company has written off about 60 percent of the purchase price of Shanghai Golden Monkey, or 45 percent of its total value of $557 million, including debt.

Many companies overpay for acquisitions, observers say. But the Campbell and Hershey experiences illustrate the difficulties that legacy packaged-food companies can have growing. Obstacles can be as simple as a trend toward healthier eating by Americans, or as complex as an unfamiliar overseas market. Other food giants, such as Kraft Foods Inc. and H.J. Heinz Co., have merged to cut costs and attain synergies, preserving profit margins.

"Big food companies like Campbell's have always focused on shelf-stable foods, and the consumer is a lot more about fresh," said Mitchell B. Pinheiro, a food analyst with Wunderlich Securities. "The manufacturing, the supply chains, the sales, the brands that the more mature, larger consumer packaged-goods companies possess don't match up well with today's consumer."

Minyuan Zhao, associate professor of management at the Wharton School at the University of Pennsylvania, said American companies such as Hershey blame the slowing Chinese economy for their problems there. But she said, "The era [in China] in which the high tide lifts all boats is over."

Campbell chief executive Denise Morrison — scheduled to deliver a keynote speech Friday at the massive Natural Products Expo West in Anaheim, Calif., as part of an effort to boost Campbell's bona fides in the natural sector — last month described the Bolthouse Farms and Garden Fresh deals "as a way to develop a long-term growth platform in packaged fresh."

But hiccups at Bolthouse — caused, in part, by drought followed by California flooding — led to two write-offs totaling $288 million on Bolthouse's fresh carrots and carrot ingredients businesses, close to 20 percent of the $1.55 billion purchase price. The company also had a recall of 3.8 million bottles of its Bolthouse Farms Protein Plus drinks.

Weather was not an issue at Garden Fresh Gourmet, a producer of fresh salsa, dips, and chips that Campbell bought for $232 million, but the Michigan company had its own problems, leading to a $65 million write-down, or more than a quarter of the purchase price.

The integration of Garden Fresh into the Bolthouse unit faltered at times, leading to the loss of supermarket customers. In addition, the nationwide expansion of the Garden Fresh brand fell flat because its Midwestern recipes did not go over well everywhere. Campbell says it has since fixed Garden Fresh.

Buying food companies is "like picking winners at racetracks," said John Stanton, a professor of food marketing at St. Joseph's University. "You've got 10 entrepreneurs, and they are all going neck-and-neck, and you've to pick the one you're going to place your bet on."

With an acquisition, though, a corporate buyer has to manage the company instead of just placing a bet on it, Stanton said.

As other chocolate companies globalized over the last two decades, Hershey mostly stuck to the United States. But it saw big opportunity in China, with  chocolate sales projected to grow at an annual compounded rate of 10 percent.

In late 2014, Hershey bought Shanghai Golden Monkey for $415 million in a two-step process, initially acquiring 80 percent and agreeing to buy the remaining 20 percent in a year.

Within months, though, John Bilbrey, Hershey's chief executive at the time, was warning Wall Street that the China deal was not what it first seemed. The Chinese distributor network was "not as stable as we believed," Bilbrey said in a conference call. Sales forecasts for 2015 were revised downward more than 50 percent. Burned, Hershey wrote off about $250 million in impairment charges.

Adding to Hershey's woes Wednesday, Bloomberg News reported that the Chinese government told Lotte Shanghai Foods – a 50-50 joint venture between Hershey and South Korea's Lotte Group – to close a factory that manufactures cocoa and chocolate products for a month. The Chinese action, confirmed by Hershey and Lotte, comes as South Korean companies say they are facing economic retaliation from China for their country's decision to deploy a missile-defense system to counter North Korea.

During a March 1 investor day in New York, Hershey Co.'s new chief executive, Michele Buck, acknowledged the problems with its China sojourn. The confections giant expects to cut about 2,700 employees, mostly overseas, and idle overseas factories that are running at about 40 percent of capacity. The research firm Euromonitor International estimates that Hershey is the No. 5 global chocolate company.

Buck said Hershey had had more success with its Krave beef jerky and Barkthins acquisitions, which market products in the United States.

Many times, said Marshall W. Meyer, emeritus professor at the Wharton School, it's hard to build a brand in China, and there can be trade barriers between regions within China, which stunts growth.

"I am not so totally optimistic as many companies who invest in China," Meyer said.