发送消息给jms队列抛出AMQ119031:无法验证用户异常

时间:2018-01-08 23:40:24

标签: jms wildfly-11

在Wildfly 11.0.0-Final中向JMS队列发送消息的代码抛出ActiveMQSecurityException [errorType = SECURITY_EXCEPTION消息= 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);

对此赞赏的任何帮助

1 个答案:

答案 0 :(得分:0)

您似乎没有为队列添加任何应用程序用户。 您必须添加一个应用程序用户,其用户名和密码必须与您为Constants.USERNAME和Constants.PASSWORD传递的值相匹配。 要添加应用程序用户,您必须开始野外操作并运行" add-user"您可以在wildfly安装的bin目录中找到它并按照说明进行操作。