Weblogic 消息驱动 Bean 从安全队列 @RunAs 读取不起作用
我有一个非常简单的 MDB,只要它读取消息的队列不安全,它就可以正常工作
。在我使用用户名保护队列后,它就不能再读取消息了,
@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 从队列中读取消息
import javax.annotation.security.RunAs; @RunAs("SomeRole")
给我一个部署错误 无法部署 EJB:来自 mdbReceiver.jar 的 MdbReceiver:映射中的预期角色
知道如何使用注释来做到这一点吗?即使没有注释我也尝试过 ...weblogic控制台中的异常是
weblogic.jms.common.JMSSecurityException:拒绝访问资源:type=
谢谢
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();
}
}
}
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")
gives me an error on deployment
Unable to deploy EJB: MdbReceiver from mdbReceiver.jar: Expected role in mapping
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
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我回答我的问题是因为我找到了解决方案:
问题是注释或在 weblogic 中存在错误,或者没有按照我的预期实现。
解决方案是在不使用旧样式注释的情况下执行此操作,
因此 MDB 是:
然后我们需要另外两个文件:
ejb-jar.xml
和
weblogic-ejb-jar.xml
角色名称并不重要,因为我可以看到主体名称很重要。
它需要有权从安全队列中读取
I answer to my question cause i found a solution :
The problem is that annotations or are buggy in weblogic or are not implemented as I expected.
Solution is to do this without annotations in old style
so MDB is:
Then we need two other files:
ejb-jar.xml
and
weblogic-ejb-jar.xml
The role name does not matter as i can see the principal name is important.
It needs to have the rights to read from the secured queue
如果您按如下方式注释 MDB,它应该可以工作:
If you annotate your MDB as follows it should work: