This discussion is archived
7 Replies Latest reply: Oct 4, 2012 6:16 AM by sabre150 RSS

UnknownHostException:http

965587 Newbie
Currently Being Moderated
Hi all,

We are migrating an application from 5.1 to 7.0 version and when we access the url which belongs to the application it throws UnknownHostException:http .This is thrown in the class

public class DAVURLConnection extends sun.net.www.protocol.http.HttpURLConnection

And the stack trace is:
10/4/12 1:15:01:244 CDT 00000027 SystemErr R java.net.UnknownHostException: http
10/4/12 1:15:01:244 CDT 00000027 SystemErr R at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:207)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at java.net.Socket.connect(Socket.java:539)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at java.net.Socket.connect(Socket.java:488)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at sun.net.www.http.HttpClient.openServer(HttpClient.java:407)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at sun.net.www.http.HttpClient$4.run(HttpClient.java:470)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at java.security.AccessController.doPrivileged(AccessController.java:251)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:452)
10/4/12 1:15:01:245 CDT 00000027 SystemErr R at sun.net.www.http.HttpClient.openServer(HttpClient.java:533)
10/4/12 1:15:01:246 CDT 00000027 SystemErr R at sun.net.www.http.HttpClient.<init>(HttpClient.java:246)
10/4/12 1:15:01:246 CDT 00000027 SystemErr R at sun.net.www.http.HttpClient.New(HttpClient.java:319)
10/4/12 1:15:01:246 CDT 00000027 SystemErr R at sun.net.www.http.HttpClient.New(HttpClient.java:336)
10/4/12 1:15:01:246 CDT 00000027 SystemErr R at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:980)
10/4/12 1:15:01:246 CDT 00000027 SystemErr R at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:959)
10/4/12 1:15:01:246 CDT 00000027 SystemErr R at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:846)
10/4/12 1:15:01:246 CDT 00000027 SystemErr R at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1024)
10/4/12 1:15:01:247 CDT 00000027 SystemErr R at com.ibm.webdav.protocol.http.DAVURLConnection.getOutputStream(DAVURLConnection.java:89)

To add more info . We did telnet for hostname to which we are trying to connect from the linux server for this we could able to telnet but when we try to connect that host through java code then we are getting the above specified stacktrace at getOutputStream() method. getOutputStream() method is overriden in above mentioned class WebDAVURLConnection and calling super.getOutputStream() method.Are we need to do any jar files inclusion after migrating to 7.0 version? Do we need to change code which uses this method ? Any suggestions.

Edited by: 962584 on Oct 4, 2012 4:57 AM
  • 1. Re: UnknownHostException:http
    EJP Guru
    Currently Being Moderated
    Post the code.
  • 2. Re: UnknownHostException:http
    965587 Newbie
    Currently Being Moderated
    The code:


    URL getUrl = new URL("ValidURL");
                   String protocol = getUrl.getProtocol();
                   int port = getUrl.getPort();
    DAVURLConnection getUrlCon = new DAVURLConnection(getUrl, protocol, port);
                   getUrlCon.setDoInput(true);
                   getUrlCon.setRequestMethod("PUT");
                   getUrlCon.setRequestProperty("Content-type", "text/xml");
                   getUrlCon.setRequestProperty("Depth", depth);
                   getUrlCon.setFollowRedirects(false);
                   authenticate(cookieList, getUrlCon, respCode);
                   getUrlCon.setDoOutput(true);
                   OutputStream os = getUrlCon.getOutputStream(); --- getting exception at this point

    ============================================

    In DAVURLConnection (Url , protocol, port) construtor, we are calling super(u, host, port) constructor of sun.net.www.protocol.http.HttpURLConnection.

    i.e public DAVURLConnection(URL u, String host, int port) throws IOException {
    super(u, host, port);
    }

    Edited by: 962584 on Oct 4, 2012 4:53 AM

    Edited by: 962584 on Oct 4, 2012 4:56 AM
  • 3. Re: UnknownHostException:http
    jwenting Journeyer
    Currently Being Moderated
    which seems to indicate your "url" parameter is not passed correctly. Unless there's an error in the "DAVUrlConnection" class, your own code is passing it "http" as the complete URL.
  • 4. Re: UnknownHostException:http
    965587 Newbie
    Currently Being Moderated
    The URL parameter is passing correct only. This URL already working in WAS 5.1 version, we are getting the error in WAS 7.0. URL is available and through telnet we can able to connect from our server but we are getting at error at getOutputStream()
  • 5. Re: UnknownHostException:http
    sabre150 Expert
    Currently Being Moderated
    962584 wrote:

    In DAVURLConnection (Url , protocol, port) construtor, we are calling super(u, host, port) constructor of sun.net.www.protocol.http.HttpURLConnection.
    Oooerrr - one is not supposed to use any of the Sun private classes (indicated by a a package starting with 'sun' ). On the surface you seem to be using the same methods as are available in java.net.HttpURLConnection but for some reason you don't mention you are not using a URL object as a factory to create a java.net.HttpURLConnection . This seems to me to be a design flaw.
  • 6. Re: UnknownHostException:http
    965587 Newbie
    Currently Being Moderated
    This is already constructed code and is running years together in WAS 5.1 for users. Now we cannot do any design changes, but if we want we can change code if needed.
  • 7. Re: UnknownHostException:http
    sabre150 Expert
    Currently Being Moderated
    962584 wrote:
    This is already constructed code and is running years together in WAS 5.1 for users. Now we cannot do any design changes, but if we want we can change code if needed.
    So change the code to do it properly and use a URL object as a factory !!!!!!!!!!!!!!!!!!

    P.S. It is irrelevant that it worked in WAS 5.1 since it relied on something that was not guaranteed to be available in later JDK and even if available may have modified functionality.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points