I am new to Java reflection. I tried to call one method of my DAO
Class using reflection, and I got the below mentioned error of illegal argument exception. Below is my code. My method contains two arguments: one is Dossier bean object and another is sessionfactory
object. I got this error when I invoke my method. I searched lot on net but did not find the proper solution.
public String getDossierDetail(HttpSession session,DoerDAO doerDao,SessionFactory sessionFactory,String requestedUser) throws ClassNotFoundException{
log.info("(getDossierDetail)Execution starts");
ReviewerOne reviewer = new ReviewerOne();
String message = "";
DoerDAO doerDaoInt = new DoerDAO();
try{
List<Dossier> dossierDetail = (List<Dossier>) session.getAttribute(ObjectConstant.dossierDetailBean);
System.out.println("dossierDetail: "+dossierDetail.size()+"product nm: "+dossierDetail.get(0).getProductName()+"requested User: "+requestedUser);
Method method = DoerDAO.class.getDeclaredMethod(requestedUser,Dossier.class,SessionFactory.class);
method.invoke(dossierDetail.get(0), sessionFactory);
}catch(Exception e){
e.printStackTrace();
log.error("(getDossierDetail)Error is: ",e);
message = e.getLocalizedMessage();
}
return message;
}
my requestedUser value is :: getReviewerOneDetail.
/** DoerDao method ********/
public void getReviewerOneDetail(Dossier dossierBean,SessionFactory sessionFactory){
log.info("(getReviewerOneDetail)Execution starts.");
try{
System.out.println("in reviewer one detail....");
}catch(Exception e){
e.printStackTrace();
log.error("(getReviewerOneDetail)Error is: ",e);
}
}