Could not obtain connection to any of these urls localhost 1099

Could not obtain connection to any of these urls localhost 1099

If you see below exception while trying to use “jnp://localhost:1099” on JBoss server:

Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
	at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1690)
	at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1761)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:695)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
	at javax.naming.InitialContext.lookup(InitialContext.java:392)
	at com.javahonk.QueueExample.example(QueueExample.java:22)
	at com.javahonk.QueueExample.main(QueueExample.java:83)
Caused by: java.net.SocketTimeoutException: Receive timed out
	at java.net.PlainDatagramSocketImpl.receive0(Native Method)
	at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:145)
	at java.net.DatagramSocket.receive(DatagramSocket.java:725)
	at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1659)
	... 6 more

Solution: It means the port you are trying to connect is not up yet. In my case I was trying to connect without starting JBoss server 🙂 and this was causing the issue. Check your JBoss server if it’s up and running or not. Below is connection parameter:

public static Context getInitialContext() throws javax.naming.NamingException {

		Properties p = new Properties();
		p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
		p.put(Context.URL_PKG_PREFIXES, " org.jboss.naming:org.jnp.interfaces");
		p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
		return new javax.naming.InitialContext(p);
	}

For more information please visit JBoss forum here

One thought on “Could not obtain connection to any of these urls localhost 1099”

Leave a Reply

Your email address will not be published. Required fields are marked *