New York CNN Business  — 

Boeing reported an unexpected loss in the third quarter Wednesday after taking a massive $2.8 billion charge related to its high profile defense and space businesses, including completing the new versions of Air Force One and its much delayed Starliner space capsule.

The company also continued to report losses from its core commercial jet unit, even with increased deliveries lifting revenue for the company in an otherwise disappointing quarter of red ink.

The charges in the defense and space businesses were for contracts where Boeing gets a fixed amount of revenue from its government clients and isn’t able to pass along cost increases.

Those programs include refurbishing two 747 jets that will become the next generation of Air Force One. The delivery of those planes was again delayed during the quarter and now won’t be completed for at least another four years.

The company is being paid $3.9 billion for the jets and has already taken a $660 million charge for losses on the planes in the first quarter of this year. CEO Dave Calhoun said at the time that the contract had been a mistake for the company.

Another source of the charge came from the Starliner program to build capsules to carry astronauts to the International Space Station. In August, Boeing pushed back the first crewed flight of the long-delayed project to early next year. Also included in the charge was a training jet for Air Force pilots as well as tanker jets and drones used to refuel planes mid-flight.

The charge resulted in an operating loss of $2.8 billion at the defense and space unit, compared to a $436 million profit it made there last year. Boeing did not specify how much of this latest charge was related to each program.

The commercial jet business delivered 112 planes in the quarter, up from 85 a year ago, including resumed deliveries of the 787 Dreamliner, which had been halted by the Federal Aviation Administration due to quality control problems. Those increased deliveries helped lift revenue 4% to $16 billion, which in turn helped Boeing have a positive cash flow in the quarter. But the commercial plane unit reported an operating loss of $643 million.

“While our cash generation was strong, our revenue and earnings were significantly impacted by losses on fixed-price development programs in our defense business, driven by higher estimated manufacturing and supply chain costs, as well as technical challenges,” Calhoun said in a statement to employees.

Boeing reported a net loss of $3.3 billion, far worse than the $132 million hit a year ago. The company had returned to profitability in the second quarter, with net income of $160 million, and analysts surveyed by Refinitiv had been forecasting another net profit of $347 million.

The company posted a core operating loss of $3.1 billion, compared to the narrow operating profit of $59 million a year earlier and earnings of $490 million on that basis in the second quarter of this year. Analysts had been expecting core operating earnings of $648 million rather than the massive loss.

The company said it should still have positive cash flow for the year, despite all the problems, which likely prevented the stock from plunging on the report. Shares of Boeing (BA), a component of the Dow Jones industrial average, were mostly flat in early trading Wednesday.