小编Ian*_*tek的帖子

如何使用嵌入式glassfish测试@RolesAllowed安全EJB3.1

我有一个@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)

出于某种原因,我无法弄清楚如何设置容器的角色来通过安全检查.我错过了什么?

junit glassfish-embedded ejb-3.1

3
推荐指数
1
解决办法
1260
查看次数

标签 统计

ejb-3.1 ×1

glassfish-embedded ×1

junit ×1