Created a new web project project in Rational Software Architect and imported Workplace into it. Right after the start discovered that it fails to run on localhost. "Huh? This is strange". Looked up the source code and found that marvelous piece of code:
[java] / * Validates HostName * @param hostName The host nema to validate * @return true, if valid. / public static boolean validateHostName( String hostName ) { return !hostName.equalsIgnoreCase("localhost") !validateIP(hostName); } [/java]
What?! It just checks for localhost and validates IP of a host name. Ok, let's look into validateIP function:
[java] / * Validates a String as a valid IP address. Checks for four parts, and that * each part represents a numeric value between 0 and 255. * @param ipAddress * @return / public static boolean validateIP( String ipAddress ) { boolean isValid = false;
StringTokenizer st = new StringTokenizer(ipAddress, "."); if ( st.countTokens() == 4 ) { isValid = true; while ( isValid st.hasMoreTokens() ) isValid = validateUnsignedByte(st.nextToken()); } return isValid; }
[/java]
Apparently there is no validation of correct IP address and Workplace should work normally if it would be started using
127.0.0.1
So I commented out first part of the code and Workspace now works on my localhost with no problems.