java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
at com.ssh.action.user.ArticleAction.showAllArticleForPage(ArticleAction.java:67)
...
Caused by: java.lang.Error: Unresolved compilation problem:
The method showAllArticleForPage(Integer) is undefined for the type ArticleService
編譯錯誤**:`ArticleService` 介面/類中缺少 `showAllArticleForPage(Integer)` 方法定義,但 `ArticleAction` 呼叫了它。導致類載入階段拋 `Error`,被反射包裝為 `InvocationTargetException`。
`InvocationTargetException` 只是包裝器,**真正原因在 `Caused by`**,本例為編譯期錯誤導致的 `NoSuchMethodError` 變體。修補 Service 方法定義即可解決。
出處:bianceng.cn