我試圖在運行時調用靜態函數(Users.dashboard()),並且出現驗證錯誤異常。用戶類繼承了CRUD.java,並且不帶任何參數。驗證錯誤,同時調用playframework控制器中的靜態函數
在Home.index():
public class Home extends Controller {
public static void index() {
for (Class<CRUD> clazz : play.Play.classloader
.getAssignableClasses(CRUD.class)) {
Dashboard d;
try {
Method m = clazz.getMethod("dashboard");
if (m != null) {
d = (Dashboard) m.invoke(clazz.newInstance(), new Object[] {});
}
} catch (SecurityException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
} catch (Exception e) {
}
}
render(dashboards);
}
控制檯輸出:在控制器
@69iahfk3j
Internal Server Error (500) for request GET /home
Oops: VerifyError
An unexpected error occured caused by exception VerifyError: (class: controllers/Home, method: index signature:()V) Register 1 contains wrong type
play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:242)
at play.Invoker$Invocation.run(Invoker.java:284)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.VerifyError: (class: controllers/Home, method: index signature:()V) Register 1 contains wrong type
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at play.utils.Java.findActionMethod(Java.java:98)
at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java:602)
at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85)
... 1 more
您可以發佈完整的異常堆棧跟蹤和Home.index()方法。也應用程序控制器代碼一起,至少包含上面的@green更新問題13 – 2012-03-04 19:11:22
。 – 2012-03-05 08:29:27