我的EJB计时器始终与UNAUTHENTICATED
用户一起运行。我试图放@RunAs
但是没有用。我尝试用反射更改值并且不起作用,我需要从中调用远程EJB,我需要有权限的用户。
@Resource
private SessionContext context;
@Schedule(second= "*/5", minute = "*", hour = "*", persistent = false)
public void executa(){
Principal callerPrincipal = context.getCallerPrincipal();
final Field field = getField(callerPrincipal.getClass(), "name");
field.setAccessible(true);
try {
field.set(callerPrincipal,"MYUSER");
} catch (IllegalAccessException e) {
e.printStackTrace();
}
this.iMyRemoteEjb.doWork()
}