add throw exception in spring factory method