I'm running GlassFish Server 4.1 and I want to call a method periodically so I am using @Schedule, the method requires a role so I added @RunAs to the class. But no matter how I try I can not get this to work.
@Singleton
@Startup
@RunAs("Tool")
public class Test {
@Resource
private SessionContext ctx;
@Schedule(minute = "*/1", hour = "*")
public void checkExpiringAgreements() {
System.out.println("Has role Tool: " + ctx.isCallerInRole("Tool"));
}
}
This runs every minute, but it prints:
Info: Has role Tool: false
If I had any hair I'd be tearing it out right now. Why doesn't this work?