Although this post focuses on the HTTP Analyzer in JDeveloper, well because I work on it, this also contains information that is relavent to other testing tools such a tcpmon and SOAPUI.
Normally in a development situation where you have everything on the same box you can simply use "localhost" as the domain name. This has a lot of advantages when working in a source controlled environment as the same strings can be used on different machines. So in this scenario you have the client, some kind of HTTP monitoring proxy, and the server running on the same machine.
So when you start the client from inside of JDeveloper we set the right proxy environment settings; but you can expect them to look something like:
-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8988 -Dhttp.nonProxHosts= -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8988 -Dhttps.nonProxHosts=
Now you would expect this mean that any request to any host will be sent via the proxy. But as noted in sun bug 6737819 the default ProxySelector will never proxy any requests to "localhost" even if you explicitly set "nonProxyHosts". This is of course a major pain for tools developers and users like.
Fortunately there is a workaround and that is to use "localhost.localdomain" instead. This is just a synomn for localhost and the proxy selector in java is not clever enough to recognize this as being the same as localhost. (Also I suspect it doesn't recognize :::1 or any of the other ipv6 localhost options)
When users get there sweaty hands on the next version of JDeveloper this is why we have moved to defaulting to "localhost.localdomain" rather than just plain old "localhost". Not because we are trying to be difficult or obtuse. :-)
Update:
Turns out this doesn't work so well on OS X. This is because the "/etc/hosts" file is missing localhost.localdomain entry. You can fix this by editing this file as root. ("sudo vi /etc/hosts") You need to alter the line:
127.0.0.1 localhost
to be
127.0.0.1 localhost localhost.localdomain
Please be carefull with this file, if you mess it up you machine may not boot properly. I have logged apple bug 6158676 to track this issue.
2 comments:
Out of curiosity, is localhost.localdomain really necessarily a synonym for localhost on all systems?
I notice that if I attempt to nslookup localhost.localdomain on Mac OS X 10.5, it does not resolve, whereas just plain localhost does.
Sod,
I checked Linux and Windows; but didn't remember to check OS X. (I don't have one that will run the vanilla JDK 6 anymore to check). I suppose you could always just add it to /etc/hosts but this is of course not the best solution.
You are very right, now I have to find something that works on that platform also. Now if only the ProxySelector had some kind of Service lookup I could just put a jar on the classpath. More bug for sun then....
Gerard
Post a Comment