Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

UnknownHostException with WLS 8.1

Posted on 2004-09-01
8
856 Views
Last Modified: 2013-12-10
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.MalformedURLException;
import java.net.UnknownHostException;
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(HttpServletRequest request, HttpServletResponse response)
    {
   
        try
        {
            System.out.println("setting properties...");
            System.getProperties().put("http.proxySet", "true");
            System.getProperties().put("http.proxyHost", "192.168.6.92");
            System.getProperties().put("http.proxyPort", "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.openStream()));
            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.openStream()));

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
0
Comment
Question by:girionis
  • 5
  • 2
8 Comments
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11952445
first, use ping command in linux to test connection

$ ping 192.168.6.92

if it's ok, then test www.yahoo.com

$ ping www.yahoo.com

0
 
LVL 35

Author Comment

by:girionis
ID: 11952475
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.
0
 
LVL 35

Author Comment

by:girionis
ID: 11996647
I still haven't found the answer. Any more thoughts on this?
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 5

Accepted Solution

by:
Becky earned 500 total points
ID: 12069004
IMHO this is a bug w/ Weblogic 8.1.  Add these parameters to your weblogic startup script to fix...

-Dhttp.proxyHost=192.168.6.92 -Dhttp.proxyPort=8080

...and restart the server.  If you use managed servers this should be in the startup script for your admin server (uninstall admin server service, add this to startup script, reinstall admin server service) and in the remote start tab of your managed server(s) (under arguments section).

-B
0
 
LVL 35

Author Comment

by:girionis
ID: 12073424
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 :)
0
 
LVL 35

Author Comment

by:girionis
ID: 12140926
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 :)
0
 
LVL 5

Expert Comment

by:Becky
ID: 12149491
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.
0
 
LVL 35

Author Comment

by:girionis
ID: 12150791
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 :(
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

-Xmx and -Xms are the two JVM options often used to tune JVM heap size.   Here are some common mistakes made when using them:   Assume BigApp is a java class file for the below examples. 1.         Missing m, M, g or G at the end …
Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question