我有一个@RolesAllowed受保护的@Stateless EJB,我正在尝试使用嵌入式GlassFish容器进行JUnit-4测试.我克服的最新障碍是用于持久性单元和安全领域的GlassFish域配置.
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);
Run Code Online (Sandbox Code Playgroud)
嵌入式GlassFish启动,我的应用程序部署,一切似乎按预期工作,直到我用@RolesAllowed注释调用EJB方法.
javax.ejb.AccessLocalException: Client not authorized for this invocation
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我无法弄清楚如何设置容器的角色来通过安全检查.我错过了什么?