I have a @RolesAllowed protected @Stateless EJB that I'm trying to JUnit-4 test with embedded GlassFish container. The most recent hurdle I've overcoming has been GlassFish domain configuration for persistence unit and security realm.
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(EJBContainer.MODULES, new File("build/classes"));
properties.put("org.glassfish.ejb.embedded.glassfish.configuration.file",
"test-resource/domain.xml");
ec = javax.ejb.embeddable.EJBContainer.createEJBContainer(properties);
Embedded GlassFish starts, my application deploys, and everything seems to work as expected until I call a EJB method with a @RolesAllowed annotation.
javax.ejb.AccessLocalException: Client not authorized for this invocation
For some reason I can not figure out how to set the container's role to pass the security check. What am I missing?