girionis
asked on
UnknownHostException with WLS 8.1
Hello,
I am using WebLogic Server 8.1 under RedHat Linux 9.0 and JDK1.4.1_05. I am trying to run the following servlet:
package smswebapp;
import java.io.*;
import java.net.MalformedURLExcep tion;
import java.net.UnknownHostExcept ion;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import javax.servlet.*;
import javax.servlet.http.*;
public class SMSServlet extends HttpServlet
{
// The session ID obtained from the clickatel gateway
private static String sessionID = null;
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
processRequest(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
processRequest(request, response);
}
/**
* Processes the request from the user.
*
* @param request - The request object
* @param response - The response object
*/
public void processRequest(HttpServlet Request request, HttpServletResponse response)
{
try
{
System.out.println("settin g properties...");
System.getProperties().put ("http.pro xySet", "true");
System.getProperties().put ("http.pro xyHost", "192.168.6.92");
System.getProperties().put ("http.pro xyPort", "8080");
// Create a URL for the desired page
URL url = new URL("http://www.yahoo.com");
System.out.println("URL object created...");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.open Stream())) ;
System.out.println("input from url obtained...");
String str;
while ((str = in.readLine()) != null)
{
System.out.println("line: " + str);
}
in.close();
}
catch (MalformedURLException e)
{
System.out.println(e);
}
catch (IOException e)
{
System.out.println(e);
}
}
}
but I am getting an UnknowHostException at this line:
BufferedReader in = new BufferedReader(new InputStreamReader(url.open Stream())) ;
I am not sure what is going on but the exact same servlet above runs fine under Tomcat 5.0. I guess WLS does not recognize the http proxy settings I am passing, or could it be something else?
Any thoughts and help is appreciated.
Regards
I am using WebLogic Server 8.1 under RedHat Linux 9.0 and JDK1.4.1_05. I am trying to run the following servlet:
package smswebapp;
import java.io.*;
import java.net.MalformedURLExcep
import java.net.UnknownHostExcept
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import javax.servlet.*;
import javax.servlet.http.*;
public class SMSServlet extends HttpServlet
{
// The session ID obtained from the clickatel gateway
private static String sessionID = null;
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
processRequest(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
processRequest(request, response);
}
/**
* Processes the request from the user.
*
* @param request - The request object
* @param response - The response object
*/
public void processRequest(HttpServlet
{
try
{
System.out.println("settin
System.getProperties().put
System.getProperties().put
System.getProperties().put
// Create a URL for the desired page
URL url = new URL("http://www.yahoo.com");
System.out.println("URL object created...");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.open
System.out.println("input from url obtained...");
String str;
while ((str = in.readLine()) != null)
{
System.out.println("line: " + str);
}
in.close();
}
catch (MalformedURLException e)
{
System.out.println(e);
}
catch (IOException e)
{
System.out.println(e);
}
}
}
but I am getting an UnknowHostException at this line:
BufferedReader in = new BufferedReader(new InputStreamReader(url.open
I am not sure what is going on but the exact same servlet above runs fine under Tomcat 5.0. I guess WLS does not recognize the http proxy settings I am passing, or could it be something else?
Any thoughts and help is appreciated.
Regards
ASKER
I have already tested them and they both work fine. The problem is with WLS since TOmcat (on the same computer) is able to run my servlet. Besides if I run it as a standalone application I am still able to connect to yahoo.
ASKER
I still haven't found the answer. Any more thoughts on this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok let me try it and will let you know... It might take a few days though since I do not currently have access to WLS :)
ASKER
I just had the time to get back to this question. It seems that it is indeed a bug with WLS 8.1 I tried the exact same code under WLS8.1 on Windows (previous installation was on Red Hat Linux 9.0) and now I am getting a different problem, authentication required. This means that it does find the proxy but it needs to authenticate against it.
Thank you for your help :)
Thank you for your help :)
No problem. I can post some code I've used to log into HTTPS connections in the past, if you need it. Will have to wait till Monday, though (it's at work). :) It's pretty straight forward - just have to remember to pass your password properly.
ASKER
Id' be glad if you could do it :)
I tried using an Authenticator but to no avail, the admin is using NTML proxy, so I have a few problems :(
I tried using an Authenticator but to no avail, the admin is using NTML proxy, so I have a few problems :(
$ ping 192.168.6.92
if it's ok, then test www.yahoo.com
$ ping www.yahoo.com