WebSphere Application Server - JNDI problem..........

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Application Server > December 2006 > JNDI problem..........





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author JNDI problem..........

2006-12-11, 1:19 pm

Hi,

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(NewConnectionInitia
lReadCallback.java:201)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback. complete(NewConnectionInitialReadCallbac
k.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))
Stephen Cocks

2006-12-11, 1:19 pm

WebSphere defaults the JNDI Provider URL to
"corbaloc:rir:/NameServiceServerRoot" when one isn't provided. The JNDI
provider for DNS expects a dns: style URL so it doesn't work. In your
application environment outside WebSphere the system is using the default
"dns:" URL (which tries to use the DNS servers configured for your OS)

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...i/jndi-dns.html

--
Stephen Cocks
WESB/WPS System Administration
<vasilakopoulos@yahoo.com> wrote in message
news:599471717.1165846477095.JavaMail.wassrvr@ltsgwas010.sby.ibm.com...
> Hi,
>
> 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(NewConnectionInitia
lReadCallback.java:201)
> at
> com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback. complete(NewConnectionInitialReadCallbac
k.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))



2006-12-12, 7:33 am

Thanks Stephen, I did as you told me and it works fine......

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com