Short version: You are missing the first argument in your call to invoke
.
Long version: You are calling
Method method = DoerDAO.class.getDeclaredMethod(requestedUser,
Dossier.class,
SessionFactory.class);
Let's say that the value of requestedUser
is getReviewerOneDetail
, then you'd look up the method
getReviewerOneDetail(Dossier arg0, SessionFactory arg1)
Next you call
method.invoke(dossierDetail.get(0), sessionFactory);
The JavaDoc states that invoke gets as first parameter the instance(!) of the class to call the method on and as second, third, ... parameters the actual parameters for your invocation.
So, what you actually trying to call in your code, is
dossierDetail.get(0).getReviewerOneDetail(sessionFactory);
which does neither match the method signature (1 parameter vs. 2 parameters), nor the instance type on which the method is called (Dossier
instead of DoerDAO
).
Because you acquire the Method
from the DoerDAO
class, I guess what you intended to write there, was actually:
method.invoke(doerDao, dossierDetail.get(0), sessionFactory);
This would translate to
doerDao.getReviewerOneDetail(dossierDetail.get(0), sessionFactory);