Vacuum energy in arbitrarily shaped cavities