When i execute the doGet of this servlet, i get an java.lang.IllegalArgumentException: wrong number of arguments. the complete code is this:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
map = new HashMap<>();
cl = new Configuration().getClass();
Method[] m = cl.getMethods();
for (int i = 0; i < m.length; i++) {
if (!m[i].getName().startsWith("get")) {
m = (Method[]) ArrayUtils.remove(m, i);
}
}
for (int i = 0; i < m.length; i++) {
try {
Object[] obj = {};
String key = m[i].getName().substring(3);
cl = Class.forName("com.nttdata.tbridge.platformmonitoring.configuration.Configuration");
map.put(key, m[i].invoke(new Configuration(), obj).toString());
} catch (Exception e) {
e.printStackTrace();
}
}
request.setAttribute("map", map);
this.getServletContext().getRequestDispatcher("/WEB-INF/index.jsp").forward(request, response);
}
}
this servlet help to print on my browser files contain of my application. Applying reflection on a class in my project that i call "Configuration" which contains functions for files reading. it seems i'm missing something in invoke() function ? Someoe can help me ? the error edit is the following:
java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
Aucun commentaire:
Enregistrer un commentaire