Can't set permission to send message (JMS)
jbauce Feb 28, 2012 9:01 AMI'm trying to use a remote client to send a message via a producer to one of my defined JMS queues. The error message says:
Exception in thread "main" javax.jms.JMSSecurityException: User: admin doesn't have permission='SEND' on address jms.queue.testQueue
I created the user "admin" on both realms using the add-user script.
I don't know if I have my security settings correct. Do I need to define roles for "admin" in the standalone application-roles.properties file?
My Security setting looks like this:
<security-setting match="#"> <permission type="send" roles="admin"/> <permission type="consume" roles="guest"/> <permission type="createNonDurableQueue" roles="guest"/> <permission type="deleteNonDurableQueue" roles="guest"/> </security-setting>
My client code looks like:
Context ic; String JBOSS_CONTEXT="org.jboss.naming.remote.client.InitialContextFactory";; Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, JBOSS_CONTEXT); props.put(Context.PROVIDER_URL, "remote://localhost:4447"); props.put(Context.SECURITY_PRINCIPAL, "admin"); props.put(Context.SECURITY_CREDENTIALS, "adminadmin"); ic = new InitialContext(props); ConnectionFactory connectionFactory = (ConnectionFactory)ic.lookup("jms/RemoteConnectionFactory"); Queue queue = (Queue) ic.lookup("jms/queue/test"); Session session = null; Connection conn = null; MessageProducer producer = null; conn = connectionFactory.createConnection("admin","adminadmin"); session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createProducer(queue); Message msg = null; msg = session.createMessage(); msg.setJMSMessageID("ID:test"); producer.send(msg); conn.close();