JNDI problem!!!!
807569Sep 26 2006 — edited Sep 27 2006Hi All:
I am trying to make an application to query a Microsoft DNS Server using JNDI, just for learning purposes, in fact I took the code below from "Thinking in Enterprise Java":
package c4u.ejb;
import java.util.Enumeration;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class DNSWalker {
public static void main(String[] args)throws Exception
{
Properties _props = new Properties();
props.put(Context.INITIALCONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
props.put(Context.PROVIDERURL, "dns://10.12.17.2");
Context c = new InitialContext(props);
Enumeration e = c.list("");
while(_e.hasMoreElements()){
System.out.println(_e.nextElement());
}
}
}
and always I try to execute this code, I got the following exception on my console:
Exception in thread "main" javax.naming.CommunicationException: DNS error during zone transfer [Root exception is java.net.SocketException: Network is unreachable]; remaining name ''
at com.sun.jndi.dns.DnsClient.queryZone(DnsClient.java:353)
at com.sun.jndi.dns.Resolver.queryZone(Resolver.java:77)
at com.sun.jndi.dns.DnsContext.populateZone(DnsContext.java:865)
at com.sun.jndi.dns.DnsContext.getNameNode(DnsContext.java:843)
at com.sun.jndi.dns.DnsContext.c_list(DnsContext.java:296)
at com.sun.jndi.toolkit.ctx.ComponentContext.p_list(ComponentContext.java:555)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.list(PartialCompositeContext.java:283)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.list(PartialCompositeContext.java:270)
at javax.naming.InitialContext.list(InitialContext.java:395)
at c4u.ejb.DNSWalker.main(DNSWalker.java:20)
Caused by: java.net.SocketException: Network is unreachable
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:364)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:207)
at com.sun.jndi.dns.Tcp.<init>(DnsClient.java:629)
at com.sun.jndi.dns.DnsClient.queryZone(DnsClient.java:303)
... 9 more
And actually I issue a ping 10.12.17.2 an my console and everything seems to be ok
64 bytes from 10.12.17.2: icmp_seq=1 ttl=128 time=0.153 ms
64 bytes from 10.12.17.2: icmp_seq=2 ttl=128 time=0.141 ms
64 bytes from 10.12.17.2: icmp_seq=3 ttl=128 time=0.155 ms
I am using Ubuntu GNU/Linux and JDK 5.03. and the DNS server is a Microsoft DNS Server.
Any help will be very appreciated.
thaks in advance