0
我在RHEL 6盒子上以root身份执行以下代码,并且它完美运行。但是,当我执行它作为任何用户权限较小,我得到一个javax.naming.NamingException:无法连接到任何服务器。服务器tride:[remote:// myserver :: myport]。这似乎是一个许可问题,但我有我的程序访问所有文件设置为777.javax.jms.ConnectionFactory仅在登录到根时连接
什么可能导致这种情况发生?
更新显然它不会解析主机名到IP地址,除非我是根。现在我正在使用ipaddress(我将使用Iputils稍后解析)。现在我正在follwoing错误:
javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:587)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:107)
at myclass.run(myclass.java:172)
at java.lang.Thread.run(Thread.java:744)
Caused by: HornetQException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:863)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:583)
InitialContext context = null;
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.setProperty("java.naming.provider.port", hostPort);
properties.setProperty("jboss.naming.client.ejb.context", "true");
properties.setProperty(Context.PROVIDER_URL, "remote://" + hostAddr + ":" + hostPort);
properties.setProperty("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
properties.setProperty("jboss.naming.client.remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "true");
properties.setProperty("jboss.naming.client.connect.options.org.xnio.Options.SSL_STARTTLS", "true");
properties.setProperty(Context.SECURITY_PRINCIPAL, userName);
properties.setProperty(Context.SECURITY_CREDENTIALS, userPass);
try
{
context = new InitialContext(properties);
ConnectionFactory cf = (ConnectionFactory) context.lookup(connectionFactory);
Destination destination = (Destination) context.lookup(jMSTopicName);
Connection conn = cf.createConnection(userName, userPass);
Session sesh = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = sesh.createConsumer(destination, selector + selectorNum);
consumer.setMessageListener(this);
jms在4447上。我在8080上有一个jboss web服务。 –