There are some exceptions: Military medical officers can be commissioned up to the age of 47 (they also don't have to retire by age 55).
Those with prior service can sometimes receive a waiver (as long as they can retire with 20 years of military service by age 55).
Aviators (Pilots and Navigators) have different age requirements, that are specific to the service.

