zig*_*ggy 3 java jboss jms hornetq jboss7.x
环境:
Jboss 7.1.0 OS Windows
我正在尝试一个简单的测试,使用Jboss和内置的HornetQ JMS提供程序来试用JMS.经过大量的游戏后,我设法得到了这种配置的响应
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "remote://localhost:4447");
env.put(Context.SECURITY_PRINCIPAL, "appuser2");
env.put(Context.SECURITY_CREDENTIALS, "s3cr3t");
Run Code Online (Sandbox Code Playgroud)
但问题是,当我运行它时,我收到以下错误:
javax.jms.JMSSecurityException: Unable to validate user: null
at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:286)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSessionInternal(ClientSessionFactoryImpl.java:695)
at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSession(ClientSessionFactoryImpl.java:264)
at org.hornetq.jms.client.HornetQConnection.authorize(HornetQConnection.java:589)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:694)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:121)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116)
at com.jms.client.ConsoleClient.runExample(ConsoleClient.java:51)
at com.jms.client.ConsoleClient.main(ConsoleClient.java:20)
Caused by: HornetQException[errorCode=105 message=Unable to validate user: null]
... 9 more
Run Code Online (Sandbox Code Playgroud)
我一直在寻找谷歌,每个例子似乎都指向如何配置HornetQ作为独立服务器的安全设置.我无法弄清楚如何在Jboss上配置用户以及我是否需要.
有任何想法吗?
小智 17
您似乎QueueConnection使用以下用户名和密码创建了一个:
QueueConnection qcon = qconFactory.createQueueConnection("appuser2","s3cr3t");
Run Code Online (Sandbox Code Playgroud)
如果您不这样做,您将收到此错误
无法验证用户:null.
如果您不想使用用户名和密码,可以使用false以下值设置安全性:
<subsystem xmlns="urn:jboss:domain:messaging:1.1">
<hornetq-server>
<security-enabled>false</security-enabled>
......
</hornetq-server>
</subsystem>
Run Code Online (Sandbox Code Playgroud)
然后您可以创建一个QueueConnection没有用户名和密码,如下所示:
QueueConnection qcon = qconFactory.createQueueConnection();
Run Code Online (Sandbox Code Playgroud)