2015-06-04 37 views
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); 

回答

0

你們是不是主辦限制的端口,如80?

+0

jms在4447上。我在8080上有一個jboss web服務。 –