[jboss-user] Re: JMS Queue works on localhost, but not remote server

samk at twinix.com samk at twinix.com
Wed Jan 23 08:27:09 EST 2008


See Thread at: http://www.techienuggets.com/Detail?tx=16123 Posted on behalf of a User

Probably not useful for you anymore but if anyone else finds this thread, they could be helped with the answer.

Check the /etc/hosts on the remote machine and replace the 127.0.1.1 by the actual ip address of the machine and restart the jboss node. This should solve this problem.

In Response To: 

Hello,

I have a JMS queue, which I've defined as follows:

in jbossmq-destinations-service.xml

<mbean code="org.jboss.mq.server.jmx.Queue"
  |      name="jboss.mq.destination:service=Queue,name=myQueue">
  |     <depends optional-attribute-name="DestinationManager"> jboss.mq:service=DestinationManager</depends>
  |     <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
  |     <attribute name="MessageCounterHistoryDayLimit">-1</attribute>
  |     <attribute name="SecurityConf">
  |       <security>
  |         <role name="guest" read="true" write="true"/>
  |         <role name="publisher" read="true" write="true" create="false"/>
  |         <role name="noacc" read="false" write="false" create="false"/>
  |       </security>
  |     </attribute>
  |   </mbean>

in jms-ds.xml
  <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
  |          name="jboss.mq:service=JMSProviderLoader,name=JMSProvider">
  |     <attribute name="ProviderName">DefaultJMSProvider</attribute>
  |     <attribute name="ProviderAdapterClass">
  |       org.jboss.jms.jndi.JNDIProviderAdapter
  |     </attribute>
  |     <!-- The combined connection factory -->
  |     <attribute name="FactoryRef">java:/XAConnectionFactory</attribute>
  |     <!-- The queue connection factory -->
  |     <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>
  |     <!-- The topic factory -->
  |     <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>
  |     <!-- Uncomment to use HAJNDI to access JMS
  |     <attribute name="Properties">
  |        java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
  |        java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
  |        java.naming.provider.url=localhost:1100
  |     </attribute>
  |     -->
  |   </mbean>
  | 

and in the server side java file

			
// Create the queue properties
  | Properties properties = new Properties();
  | 		
  | // Set the context properties
  | properties = new Properties();
  | properties.put(Context.INITIAL_CONTEXT_FACTORY,
  | 	"org.jnp.interfaces.NamingContextFactory");
  | properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
  | properties.put(Context.PROVIDER_URL, "localhost");
  | 	
  | // STEP I - Create Regular Queue
  | // Initialize the context
  | incomingContext = new InitialContext(properties);
  | 
  | // Obtain the JMS queue
  | incomingQueue = (Queue) incomingContext.lookup("queue/myQueue");
  | // Create the connection factory connection and the connection session 
  | incomingConnectionFactory = (QueueConnectionFactory) incomingContext.lookup("UIL2ConnectionFactory");
  | 
  | incomingQueueConnection = incomingConnectionFactory.createQueueConnection();
  | 
  | incomingQueueConnection.start();
  | 
  | incomingQueueSession = incomingQueueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  | 
  | // Create the JMS Sender
  | incomingQueueReceiver = incomingQueueSession.createReceiver(incomingQueue);

I use the following code in the client to connect to the server's JMS queue:

  | // Create the queue properties
  | properties = new Properties();
  | 
  | // Set the context properties
  | properties = new Properties();
  | properties.put(Context.INITIAL_CONTEXT_FACTORY,
  | "org.jnp.interfaces.NamingContextFactory");
  | properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
  | properties.put(Context.PROVIDER_URL, "SERVER_IP_ADDRESS");
  | 
  | // STEP I - Create Regular Queue
  | // Initialize the context
  | incomingContext = new InitialContext(properties);
  | 
  | // Obtain the JMS queue
  | outgoingQueue = (Queue) outgoingContext
  | .lookup("queue/myQueue");
  | 
  | // Create the connection factory connection and the connection
  | // session
  | incomingConnectionFactory = (QueueConnectionFactory) incomingContext
  | .lookup("UIL2ConnectionFactory");
  | incomingQueueConnection = incomingConnectionFactory
  | .createQueueConnection();
  | 
  | incomingQueueConnection.start();
  | 
  | incomingQueueSession = incomingQueueConnection.createQueueSession(
  | false, Session.AUTO_ACKNOWLEDGE);

Now this works when both the client and the server are on localhost. It also works when using my two development machines at home (they are both connected to the same router at home). But, when I try to connect to my productive server (which is at a remote location and not at home :), I get the following error when I try to connect to the queue from my client (I get this error at the client machine):


  | javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is: 
  | 	java.net.ConnectException: Connection refused: connect]
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
  | 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
  | 	at com.myProject.manager.ServerManagerJMSProducer.initialize(ServerManagerJMSProducer.java:124)
  | 	at com.myProject.manager.ServerManagerJMSProducer.getInstance(ServerManagerJMSProducer.java:168)
  | 	at com.myProject.manager.myProjectServerManager.run(myProjectServerManager.java:50)
  | 	at java.lang.Thread.run(Thread.java:595)
  | Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested exception is: 
  | 	java.net.ConnectException: Connection refused: connect
  | 	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
  | 	at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
  | 	at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
  | 	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:94)
  | 	at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
  | 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
  | 	... 6 more
  | Caused by: java.net.ConnectException: Connection refused: connect
  | 	at java.net.PlainSocketImpl.socketConnect(Native Method)
  | 	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
  | 	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
  | 	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
  | 	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
  | 	at java.net.Socket.connect(Socket.java:519)
  | 	at java.net.Socket.connect(Socket.java:469)
  | 	at java.net.Socket.<init>(Socket.java:366)
  | 	at java.net.Socket.<init>(Socket.java:179)
  | 	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
  | 	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
  | 	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)
  | 	... 11 more
  | java.lang.NullPointerException
  | 	at com.myProject.manager.ServerManagerJMSProducer.clearQueueMessages(ServerManagerJMSProducer.java:93)
  | 	at com.myProject.manager.myProjectServerManager.run(myProjectServerManager.java:63)
  | 	at java.lang.Thread.run(Thread.java:595)
  | Exception in thread "myProject Server Manager" java.lang.NullPointerException
  | 	at com.myProject.manager.ServerManagerJMSProducer.sendServerQuery(ServerManagerJMSProducer.java:82)
  | 	at com.myProject.manager.myProjectServerManager.run(myProjectServerManager.java:65)
  | 	at java.lang.Thread.run(Thread.java:595)

Any ideas?

Thanks in advance,
Onur





More information about the jboss-user mailing list