我在RHEL 6框上以root身份执行以下代码,它运行完美。但是当我执行它作为任何权限较小的用户时,我得到一个javax.naming.NamingException:无法连接到任何服务器。服务器tride:[remote:// myserver :: myport]。这似乎是一个权限问题,但我将我的程序访问的所有文件设置为777。
可能导致这种情况发生的原因是什么?
显然更新它不会将主机名解析为ip地址,除非我是root用户。现在我正在使用ipaddress(我将使用Iputils稍后解决)。现在我遇到了以下错误:
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);
答案 0 :(得分:0)
您是否尝试托管受限制的端口,例如80?