Solved

UnknownHostException with WLS 8.1

Posted on 2004-09-01
8
853 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
Comment Utility
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
Comment Utility
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
Comment Utility
I still haven't found the answer. Any more thoughts on this?
0
 
LVL 5

Accepted Solution

by:
Becky earned 500 total points
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 35

Author Comment

by:girionis
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

-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 …
Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now