I use the following code to do a Domain Lookup and check for the MX record:
String hostName is in the form e.g. yahoo.com
boolean domainLookup( String hostName ) throws NamingException {
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial",
"com.sun.jndi.dns.DnsContextFactory");
DirContext ictx = new InitialDirContext( env );
Attributes attrs = ictx.getAttributes( hostName, new String[] { "MX" });
Attribute attr = attrs.get("MX");
System.out.println("The value of MX is: " + attr);
if( attr == null ) {
return (false);
} else {
return (true);
}
}
When I use it in an application environment it works fine.......
But when when I try to use it with a servlet and websphere 6.0 I am having the exception below.
Does anyone know if this is a websphere thing (I am not familiar with
websphere), or it's just that this piece of code only works in an application
level; if the second is the case, can someone give me instructions (or point
me to a tutorial) on how to do this in a servlet environment?
many thanks,
mike
corbaloc:rir:/NameServiceServerRoot is not a valid DNS pseudo-URL
[08/12/06 09:25:58:441 GMT] 00000065 SystemErr R javax.naming.ConfigurationException: corbaloc:rir:/NameServiceServerRoot is not a valid DNS pseudo-URL
at com.sun.jndi.dns.DnsContextFactory.urlToContext(DnsContextFactory.java:100)
at com.sun.jndi.dns.DnsContextFactory.getInitialContext(DnsContextFactory.java:61)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:675)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:257)
at javax.naming.InitialContext.init(InitialContext.java:233)
at javax.naming.InitialContext.<init>(InitialContext.java:209)
at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:94)
at mike.EmailValidator.domainLookup(EmailValidator.java:100)
at mike.EmailValidator.getStatus(EmailValidator.java:82)
at uk.co.hsv.web.RegisterCustomer.doPost(RegisterCustomer.java:150)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:80)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1657)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:201)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Try adding the following line
env.put("java.naming.provider.url", "dns:");
or something similar to the following (as adapted for your local domain).
env.put("java.naming.provider.url",
"dns://mydnsserver.mydomain.com/mydomain.com");
More details on accessing DNS via JNDI at
http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-dns.html
--
Stephen Cocks
WESB/WPS System Administration
<vasilak...@yahoo.com> wrote in message
news:599471717.1165846477...@ltsgwas010.sby.ibm.com...