Class Constructor fails throwing Exception on Class Loading

前端 未结 1 1693
隐瞒了意图╮
隐瞒了意图╮ 2021-01-28 14:25

I have a constructor that fails on the first call to new because an Exception of class javax.persistence.NoResultException being catch in one of the Cl

相关标签:
1条回答
  • 2021-01-28 15:08
    1. The class is loaded into the ClassLoader on first access. The first 'new' statement in your code loads the class into the ClassLoader, which subsequently checks whether it actually has access to all the dependencies of your class (ie. the NoResultException).
    2. You're not making it clear what is being thrown by the ClassLoader, but my guess is it does throw a ClassNotFoundException detailing that the NoResultException is not on your classpath, so it cannot be loaded. That's also why it works when you remove the offending import and catch.
    0 讨论(0)
提交回复
热议问题