Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

UnknownHostException with WLS 8.1

Posted on 2004-09-01
8
Medium Priority
?
878 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
Becky earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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