0
I’m in a very strange situation.
I get it from my Bean
the following arguments:
#{segurancaBean.callSubAcaoMethod(subAcao, moduloBean.class.name, modulo.id)}
This method is dynamic:
public void callSubAcaoMethod(Acao acao, String bean, Long id){
try {
Class<?> clazz = Class.forName(bean);
Method method = clazz.getMethod(acao.getTipoAcao().getNmBean(), Long.class);
Object obj = clazz.newInstance();
Object ins = new Object();
ins = method.invoke(obj, id);
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) {
Logger.getLogger(SegurancaBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
Of this method I will receive:
Name of my generic method
Name of my class for dynamic instance
ID of the object that will come from view
And below is the method that will be used:
@Override
public void btnAlterar(Long id){
Modulo m = new Modulo();
m = moduloServico.pesquisar(id);
}
Now comes the weird part.
Whether in this my method or put one System.out.println("alguma mensagem")
or Modulo m = new Modulo();
or print on screen the ID I receive parameter works normally!
Now when I go to do any operation related to instantiating an object, I have the error:
java.lang.reflect.Invocationtargetexception
The line m = moduloServico.pesquisar(id);
is an example that generates this error.
In detail, I put in mine view
also a direct button that accesses the method without going through the callSubAcaoMethod
and works normal! I can instantiate and do whatever you want, IE, would not be problem of my service.