从安全队列@RunAs读取Weblogic消息驱动的Bean不起作用 [英] Weblogic Message Driven Bean reading from a secured queue @RunAs does not work

查看:123
本文介绍了从安全队列@RunAs读取Weblogic消息驱动的Bean不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的MDB,只要不安全地读取消息的队列,它就可以正常工作

I have a MDB very simple which works fine as long as the queue from where it reads messages is not secured

使用用户名保护队列后,它将无法再读取消息

After I secure the Queue with a username it can;t read messages anymore

@MessageDriven(mappedName = "DistributedQueueTest")

public class MdbReceiver implements MessageListener {
@Resource
private MessageDrivenContext mdc;

@Override
public void onMessage(Message inMessage) {
TextMessage msg = null;
try {
msg = (TextMessage) inMessage;
System.out.println("Test MdbReceiver Message received : " + msg.getText());
} catch (JMSException e) {
e.printStackTrace();
mdc.setRollbackOnly();
}
}

}

我尝试了各种@RunAs批注 @weblogic.jws.security.RunAs(role="Joan",mapToPrincipal="ccc_user")允许ccc_user从队列中读取消息

I tried with all kind of @RunAs annotations @weblogic.jws.security.RunAs(role="Joan",mapToPrincipal="ccc_user") where ccc_user is alowed to read messages from the queue

import javax.annotation.security.RunAs; @RunAs("SomeRole")给我一个部署错误 无法部署EJB:mdbReceiver.jar中的MdbReceiver:映射中的预期角色

import javax.annotation.security.RunAs; @RunAs("SomeRole") gives me an error on deployment Unable to deploy EJB: MdbReceiver from mdbReceiver.jar: Expected role in mapping

任何想法我该如何使用注释?我尝试了即使没有注释 ...与weblogic控制台中的实例相同

Any idea how can i do this with annotations ? I tried even without annotations ...same the exeption in weblogic console is

weblogic.jms.common.JMSSecurityException: Access denied to resource: type=<jms>, application=UNIV_REC_Module, destinationType=queue, resource=DistributedQueueTest, action=receive

谢谢

推荐答案

如果您对MDB进行如下注释,则它应该可以工作:

If you annotate your MDB as follows it should work:

@MessageDriven(name = "MdbReceiver", mappedName = "DistributedQueueTest")
@DeclareRoles({"Loan"})
@RolesAllowed("Loan")
public class MdbReceiver implements MessageListener {
...
}

这篇关于从安全队列@RunAs读取Weblogic消息驱动的Bean不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆