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
If you annotate your MDB as follows it should work:
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