Отправить сообщение в очередь jms выдает AMQ119031: невозможно проверить исключение пользователя

Код для отправки сообщения в очередь JMS в Wildfly 11.0.0-Final выбрасывает ActiveMQSecurityException [errorType = SECURITY_EXCEPTION message = AMQ119031: Невозможно проверить пользователя] исключение, если я предоставляю учетные данные для метода createConnection ().

Выполните шаги, указанные в руководстве по быстрому запуску ниже, чтобы добавить пользователя, создать очередь https://github.com/wildfly/quickstart/tree/master/helloworld-jms.

Он отлично работает, если я отключу безопасность в standalone-full.xml

Ниже приведены сведения об исключениях и коде для отправки сообщения в очередь.

Исключение:

2018-01-08 18:20:44,641 ERROR [org.apache.activemq.artemis.core.server] (default I/O-10) AMQ224018: Failed to create session: ActiveMQSecurityException[errorType=SECURITY_EXCEPTION message=AMQ119031: Unable to validate user]
at org.apache.activemq.artemis.core.security.impl.SecurityStoreImpl.authenticate(SecurityStoreImpl.java:144)
at org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.createSession(ActiveMQServerImpl.java:1283)
at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQPacketHandler.handleCreateSession(ActiveMQPacketHandler.java:158)
at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQPacketHandler.handlePacket(ActiveMQPacketHandler.java:81)
at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.handlePacket(ChannelImpl.java:633)
at org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl.doBufferReceived(RemotingConnectionImpl.java:379)
at org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:362)
at org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:621)
at org.apache.activemq.artemis.core.remoting.impl.netty.ActiveMQChannelHandler.channelRead(ActiveMQChannelHandler.java:69)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
at org.xnio.netty.transport.AbstractXnioSocketChannel$ReadListener.handleEvent(AbstractXnioSocketChannel.java:443)
at org.xnio.netty.transport.AbstractXnioSocketChannel$ReadListener.handleEvent(AbstractXnioSocketChannel.java:379)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)

Код

final Properties env = new Properties();
            env.put(Context.INITIAL_CONTEXT_FACTORY, Constants.INITIAL_CONTEXT_FACTORY);
            env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, Constants.PROVIDER_URL));
            env.put(Context.SECURITY_PRINCIPAL, Constants.USERNAME);
            env.put(Context.SECURITY_CREDENTIALS, Constants.PASSWORD);
            namingContext = new InitialContext(env);

            // Perform the JNDI lookups
            ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(Constants.JMS_CONNECTION_FACTORY);

            Destination destination = (Destination) namingContext.lookup(Constants.JMS_DESTINATION);

            connection = connectionFactory.createConnection(Constants.USERNAME,Constants.PASSWORD);
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(destination);

            Message msg = session.createTextMessage(Constants.DEFAULT_MESSAGE+"1");
            producer.send(msg);

Любая помощь по этому поводу ценится


person Mohan    schedule 08.01.2018    source источник


Ответы (1)


Похоже, вы не добавили в очередь ни одного пользователя приложения. Вы должны добавить пользователя приложения с именем пользователя и паролем, которые должны соответствовать значениям, которые вы передаете для Constants.USERNAME и Constants.PASSWORD. Для добавления пользователя приложения вам необходимо запустить wildfy и запустить сценарий «add-user», который вы можете найти в каталоге bin вашей установки wildfly и следуя инструкциям.

person Gianluca Gizzi    schedule 23.02.2018