IOException on httpURLConnection.getInputStream();

Hello !
I have written some code to transfer a HTTP Request received on a servlet... but I'm catching an IOException when getting inputstream
at the end....
I though that adding a setDoInput(true) would solve the problem but
the code stops on it instead...
Thanks to help me,
Bye,
Ludovic, France
public int transferRequest(String fullRequestURL, HttpServletRequest request, byte[] body)
     try
          // Construct URL
          URL url = new URL(fullRequestURL);
          // Open URL and get input stream ...
          HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
          // Getting request type informations (method requestURI protocol)
          String method = request.getMethod();
          // Set method
          httpURLConnection.setRequestMethod(method);
          // Set output mode to true
          httpURLConnection.setDoOutput(true);
          // Temp string used in loop statement
          String key = "";
          String value = "";
          // Then set all header parameters
     Enumeration e = request.getHeaderNames();
     while (e.hasMoreElements())
     // Get next header key
     key = (String)e.nextElement();
     // Set forward request with it
     httpURLConnection.setRequestProperty(key, request.getHeader(key));
} /* end of while */
          // Open output stream
          OutputStream outputStream = httpURLConnection.getOutputStream();
          // Write body into stream
          outputStream.write(body);
          // Flush and close the streams
          outputStream.flush();
          outputStream.close();
          //httpURLConnection.setDoInput(true);
          // Open an input stream
          InputStream urlInputStream = httpURLConnection.getInputStream();
          // Initiate byte[] to read from URL input stream
          int responseCode = httpURLConnection.getResponseCode();
          // Flush and close the streams
          urlInputStream.close();
          httpURLConnection.disconnect();
          // Return the byte array
          return responseCode;
     catch (UnknownServiceException unknownServiceException)
          unknownServiceException.printStackTrace();
     catch (MalformedURLException malformedURLException)
          malformedURLException.printStackTrace();
     catch (ProtocolException protocolException)
          protocolException.printStackTrace();
     catch (IOException aIOException)
          aIOException.printStackTrace();
     catch (Exception aException)
          aException.printStackTrace();
     // At this point, an error occured !
     return 500;
} /* end of transferRequest */

An info:
This code works only when using no proxy... but I must use a proxy !

Similar Messages

  • HttpURLConnection.getInputStream FileNotFoundException

    Hy all,
    when i try to accessa business servlet from a presentation serlvet i get
    the folowing exception
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at java.io.IOException.<init>(Compiled Code)
    at java.io.FileNotFoundException.<init>(Compiled Code)
    at
    sun.net.www.protocol.http.HttpURLConnection.getInputStream(Compiled
    Code)
    at
    servlets_edomus.U1AB00JSBucleAbonado.obtenMensaje(U1AB00JSBucleAbonado.java:519)
    This only happen when i protect all the servlets with a acl, bun not
    when this acl is not installed.
    Somebody know about it
    Thanks in advance
    Ignacio Ramos Garcia
    Division TSO
    Area de Telecomunicaciones
    Tecsidel
    C/ Enrique Jardiel Poncela, 6
    28016 Madrid
    Tel: (+34) 91 353 08 19
    Fax: (+34) 91 353 08 81
    <mailto:[email protected]>
    www.tecsidel.es

    Since all of your ACLs are at the webserver tier, and all of your
    servlets are at the appserver tier, this shouldn't be happening.
    How are are you forwarding from presentation servlet to business
    servlet? Are you resistering your business servlet in your
    web.mxl/ias-web.xml? Can you include more of your kjs log?
    David
    Ignacio Ramos Garcia wrote:
    Hy all,
    when i try to accessa business servlet from a presentation serlvet i get
    the folowing exception
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at java.io.IOException.<init>(Compiled Code)
    at java.io.FileNotFoundException.<init>(Compiled Code)
    at
    sun.net.www.protocol.http.HttpURLConnection.getInputStream(Compiled Code)
    at
    servlets_edomus.U1AB00JSBucleAbonado.obtenMensaje(U1AB00JSBucleAbonado.java:519)
    This only happen when i protect all the servlets with a acl, bun not
    when this acl is not installed.
    Somebody know about it
    Thanks in advance

  • HttpUrlConnection.getInputStream() does not return for a particular website

    Hi,
    In my code, I am using an instance of java.net.HttpUrlConnection to "get" a web page. I am able to do it for all websites - except a particular website [Summary is at the end of this post]. The program hangs [for 10+ minutes and then throws an exception ] when I invoke
    InputStream err = httpCon.getErrorStream();
    System.out.println("Error is : " + err); // I get err as "null"
    // It hangs below for 10+ minutes and then throws an exception
    httpUrlConnection.getInputStream(); // httpUrlConnection is a valid
    I get an error when I try to get the webpage using I.E or Netscape too.
    So most likely there is some problem with the website. However I do not want my program to hang for 10+ minutes.
    I even tried to get the headers but even that invocation blocks:
    System.out.println("Reading header ........");
    for(int i = 1; i < 100; i++) {
    str = httpCon.getHeaderFieldKey(i); // <<<<<-- HANGS HERE!!!
    if(str == null || str.length() <= 0) {
    System.out.println("Header stopped reading at: " + i);
    break;
    System.out.println(str + ": " + httpCon.getHeaderField(str));
    I get an exception trace after 10+ minutes :
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:699)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:604)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:697)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:604)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:510)
    at com.panacya.dp.xml.HttpInputSource.processResponse(HttpInputSource.java:440)
    at com.panacya.dp.xml.HttpInputSource.get(HttpInputSource.java:398)
    Summary:
    1. Works for most of the websites but not for at least one [out of 30+ I tried]
    2. httpUrlConnection.getErrorStream() returns a null.
    3. httpUrlConnection.getInputStream() blocks for 10+ minutes and the httpUrlConnection.getHeaderFieldKey() also blocks.
    4. After 10+ minutes the program throws an exception.
    Q) How do make the getInputStream() call as non-blocking or have a tweakable timeout? [better still check if the call getInputStream()  should be made in the first place].
    Thanks,
    A C

    very simple... start a new thread with a timer... create a variable in your main thread... if you recieve a request (at least one) before the timer runs out... then set the variable in the main thread to true, so when the thread runs out it will not throw an exception.... on the other hand if you do not receive a request... the thread will run out... see that the variable in the main thread is still false... so then... it willl throw a exception... that you can catch... and work with from there...
    Have fun...
    matt

  • FileNotFoundException during HttpURLConnection.getInputStream()

    I keep getting a FileNotFoundException when I do the following:
    Open a connection to a URL
    Get the OutputStream
    Write something to the OutputStream
    Flush and close the OutputStream
    Get the InputStream
    Read the data
    Close the InputStream
    Get the OutputStream again
    Write more data to the OutputStream
    Flush and close the OutputStream
    Get the InputStream again
    It's always OK up until the point that I get the InputStream for the second time. I looked through the archives and saw that some people were getting this error if they hadn't closed the output stream befored opening the input stream or if they hadn't set the request method to POST, doInput and doOutput to true, and useCaches to false. I checked my code and I am doing all of these things.
    Any suggestions on why this might be happening? Your help is very appreciated.

    Figured out the problem. The error was caused by not having a trailing slash in the URL.
    Thanks!

  • On Windows 7 HttpURLConnection.openConnection() throws IOException

    Hi Team,
    In our application we have a to create httpURLCOnnection (url.openConnection())which works fine on Windows XP but throws IOException on Windows7. Does anybody know which settings need to be enabled on windows 7 to resolve this issue?
    Any response would be appreciated. Thanks in Advance.

    Hello Team,
    I have a specific exception which I get when trying to open a url on Windows 7 with IIS authentication enabled. We get exception when trying to get response code of HTTP Connection
    java.io.IOException: Authentication failure
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    Same code works find on windows XP. Do I need to do any specific settings on Windows7 to work this?
    Thanks in Advance.

  • An IOException thrown when I try to upload a file to my blob container

    Hi all, when I using Java to upload a FLV to my free trial storage account, an IOException occurs, can anybody tell me what's the reason for this problem? and how to solve this problem?
    // Dependency in my project.
    <dependency>
        <groupId>com.microsoft.windowsazure</groupId>
        <artifactId>microsoft-windowsazure-api</artifactId>
        <version>0.4.4</version>
    </dependency>
    // The source code used for uploading a file.
    public static void upload(String containerName, File localFile, String blobAddressUri) throws URISyntaxException,
    StorageException, InvalidKeyException, FileNotFoundException, IOException {
    long startTime = System.currentTimeMillis();
    // Retrieve storage account from connection-string.
    CloudStorageAccount storageAccount = CloudStorageAccount.parse(STORAGE_CONNECTION_STRING);
    // Create the blob client.
    CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
    // Get a reference to a container.
    // The container name must be lower case.
    CloudBlobContainer container = blobClient.getContainerReference(containerName);
    if (!container.exists()) {
    // Create the container if it does not exist.
    createContainer(containerName);
    // Create or override the "myvideo.avi" blob with contents from a local file.
    CloudBlockBlob blob = container.getBlockBlobReference(blobAddressUri);
    try {
    blob.upload(new FileInputStream(localFile), localFile.length());
    } catch (Exception e) {
    // Retry again 2 seconds later.
    try {
    Thread.sleep(2000L);
    } catch (InterruptedException ie) {
    // LOG.error("2秒后重试一次", ie);
    blob.upload(new FileInputStream(localFile), localFile.length());
    long endTime = System.currentTimeMillis();
    LOG.info("Uploaded file '{}' (length={}) to Azure, startTime={}, endTime={}, elpased={} ms", new Object[] {
    localFile.getAbsoluteFile(), localFile.length(), startTime, endTime, (endTime - startTime) });
    java.io.IOException
            at com.microsoft.windowsazure.services.core.storage.utils.Utility.initIOException(Utility.java:563)
            at com.microsoft.windowsazure.services.blob.client.BlobOutputStream$1.call(BlobOutputStream.java:377)
            at com.microsoft.windowsazure.services.blob.client.BlobOutputStream$1.call(BlobOutputStream.java:361)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: com.microsoft.windowsazure.services.core.storage.StorageException: The server encountered an unknown failure:
            at com.microsoft.windowsazure.services.core.storage.StorageException.translateException(StorageException.java:120)
            at com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.executeWithRetry(ExecutionEngine.ja
    va:166)
            at com.microsoft.windowsazure.services.blob.client.CloudBlockBlob.uploadBlockInternal(CloudBlockBlob.java:645)
            at com.microsoft.windowsazure.services.blob.client.CloudBlockBlob.uploadBlock(CloudBlockBlob.java:582)
            at com.microsoft.windowsazure.services.blob.client.BlobOutputStream$1.call(BlobOutputStream.java:365)
            ... 9 more
    Caused by: java.io.IOException: Error writing to server
            at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:578)
            at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:590)
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1193)
            at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
            at com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.processRequest(ExecutionEngine.java
    :332)
            at com.microsoft.windowsazure.services.blob.client.CloudBlockBlob$3.execute(CloudBlockBlob.java:633)
            at com.microsoft.windowsazure.services.blob.client.CloudBlockBlob$3.execute(CloudBlockBlob.java:613)
            at com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.executeWithRetry(ExecutionEngine.ja
    va:112)
            ... 12 more

    Hi I am also getting the same IO Exception error.
    15/01/07 09:07:13 INFO mapreduce.Job: Task Id : attempt_1420542176512_0075_m_000234_0, Status : FAILED
    Error: java.io.IOException
                    at com.microsoft.windowsazure.storage.core.Utility.initIOException(Utility.java:493)
                    at com.microsoft.windowsazure.storage.blob.BlobOutputStream$1.call(BlobOutputStream.java:370)
                    at com.microsoft.windowsazure.storage.blob.BlobOutputStream$1.call(BlobOutputStream.java:354)
                    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
                    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
                    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
                    at java.lang.Thread.run(Thread.java:745)
    Caused by: com.microsoft.windowsazure.storage.StorageException: The server encountered an unknown failure:
                    at com.microsoft.windowsazure.storage.StorageException.translateException(StorageException.java:179)
                    at com.microsoft.windowsazure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:266)
                    at com.microsoft.windowsazure.storage.blob.CloudBlockBlob.uploadBlockInternal(CloudBlockBlob.java:717)
                    at com.microsoft.windowsazure.storage.blob.CloudBlockBlob.uploadBlock(CloudBlockBlob.java:688)
                    at com.microsoft.windowsazure.storage.blob.BlobOutputStream$1.call(BlobOutputStream.java:358)
                    ... 7 more
    Caused by: java.io.IOException: Error writing to server
                    at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:625)
                    at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:637)
                    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1321)
                    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
                    at com.microsoft.windowsazure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:176)
                    ... 10 more
    Please Help

  • NullPointerException while connecting through HTTPUrlConnection with JavaUpdate 51

      Hi,
    My java version is
    java version "1.7.0_51"
    Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
    I have a server/Device having untrusted certificate. When i connect to this device using HttpURLConnection its throwing null pointer exception as below.
    The update51 has introduced many security things, but i belive it should pop-up a dialogue for the untrusted certificate not the NPException. Seems like a clear bug in Oracle java update51. I have created a bug in bugs.sun.com but i dont see my bug id is visible in their bug database.
    Steps to reproduce.
    ----------------------------------------------- Start----------------------------------------
    package com.xyz;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
    public class Test {
        public static void main(String[] args) throws IOException {
            TrustManager.installDeployTrustManager();  // We are using "com.sun.deploy.security.X509Extended7DeployTrustManager".
            URL url = new URL("https://hostname/admin/version.xml");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
           BufferedReader br =
                 new BufferedReader(
                         new InputStreamReader(conn.getInputStream()));
         String input;
         while ((input = br.readLine()) != null){
            System.out.println(input);
    ---------------------------End of code snippet----------------------
    replace the URL with your server Ip address which is having untrusted certificate. or change your PC time to feb 2015 and give the google ip address in the URL.
    I see the following exception.
    --------------------------------Start of the exception--------------------
    java.lang.NullPointerException
        at com.sun.deploy.security.DeployManifestChecker.printWarningsIfRequired(Unknown Source)
        at com.sun.deploy.security.TrustDeciderDialog.doShowDialog(Unknown Source)
        at com.sun.deploy.security.TrustDeciderDialog.showDialog(Unknown Source)
        at com.sun.deploy.security.TrustDeciderDialog.showDialog(Unknown Source)
        at com.sun.deploy.security.X509Extended7DeployTrustManager.checkServerTrusted(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at com.cisco.launcher.Test.main(Test.java:17)
    Exception in thread "main" javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Java couldn't trust Server
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at com.xyz.Test.main(Test.java:17)
    Caused by: java.security.cert.CertificateException: Java couldn't trust Server
        at com.sun.deploy.security.X509Extended7DeployTrustManager.checkServerTrusted(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
        ... 12 more
    -------------------------------------------------End-------------------------------------------
    Further note:
    i see the doShowDialog() function in com.sun.deploy.security.TrustDeciderDialog has a new call to printWarningsIfRequired in DeployManifestChecker class.
    static void printWarningsIfRequired(URL paramURL, AppInfo paramAppInfo)
        String str1 = (String)ToolkitStore.get().getAppContext().get("deploy-" + paramURL);
        Resource localResource = ResourceProvider.get().getCachedResource(paramURL, str1);
    /// But here the str1 itself null or the Map doesnt have any key called "deploy-" + paramURL. So i guess its failing there.
    In my opinion the call to this function should be available only incase of a webstart and not for the standalone applications.

    I get the same error and try to turn off hostname verification by using the option :
    -Dweblogic.security.SSL.ignoreHostnameVerification=true
    but it does not seem to take this option. But wl 8.1 sp2 works. It starts fail to work since 8.1 sp3. I am looking for a solution as well. Any help would be appreciated.

  • An IOException was thrown trying to access the WSDL at the given URL.

    Hello
    I deployed webservices on weblogic 8.1.5. I defined Security policy on webservices. The server is allowed to access from both inside and outside our domain. When I access with internal ip address, trying to test methods from Launch Test Page from Admin console. When I test a method, it prompts for user name and password. I enter username and password, the invocation is successful.
    After I access Launch Test Page with external ipaddress (from outside the domain), trying to test method, the server did not ask me username and password, I get following exception. The only port open to external world is 80. The apache is configured with wlplugin and divert all trafic to port 7001.
    I was wondering if any one has seen this and how did you fix. Please advise. I appriciate your help.
    Thank you,
    Balaji
    <Apr 18, 2006 5:50:12 AM CDT> <Info> <WebService> <BEA-220094> <An IOException was thrown trying to access the WSDL at the given URL.>
    <Apr 18, 2006 5:50:12 AM CDT> <Info> <WebService> <BEA-220034> <A stack trace associated with message 220094 follows:
    java.io.FileNotFoundException: Response: '403: Forbidden' for url: 'http://XXX.XXX.XX.XX:80/eventws/EventManagementService?WSDL'
    at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:425)
    at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:28)
    at weblogic.webservice.tools.wsdlp.DefinitionFactory.createDefinition(DefinitionFactory.java:126)
    at weblogic.webservice.tools.wsdlp.WSDLParser.<init>(WSDLParser.java:76)
    at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:108)
    at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:84)
    at weblogic.webservice.server.servlet.ServletBase.invokeOperation(ServletBase.java:295)
    at weblogic.webservice.server.servlet.WebServiceServlet.invokeOperation(WebServiceServlet.java:343)
    at weblogic.webservice.server.servlet.ServletBase.handleGet(ServletBase.java:266)
    at weblogic.webservice.server.servlet.ServletBase.doGet(ServletBase.java:158)
    at weblogic.webservice.server.servlet.WebServiceServlet.doGet(WebServiceServlet.java:254)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    >
    <Apr 18, 2006 5:51:32 AM CDT> <Info> <WebService> <BEA-220094> <An IOException was thrown trying to access the WSDL at the given URL.>
    <Apr 18, 2006 5:51:32 AM CDT> <Info> <WebService> <BEA-220034> <A stack trace associated with message 220094 follows:
    java.io.FileNotFoundException: Response: '403: Forbidden' for url: 'http://XXX.XXX.XX.XX:80/eventws/EventManagementService?WSDL'
    at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:425)
    at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:28)
    at weblogic.webservice.tools.wsdlp.DefinitionFactory.createDefinition(DefinitionFactory.java:126)
    at weblogic.webservice.tools.wsdlp.WSDLParser.<init>(WSDLParser.java:76)
    at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:108)
    at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:84)
    at weblogic.webservice.server.servlet.ServletBase.invokeOperation(ServletBase.java:295)
    at weblogic.webservice.server.servlet.WebServiceServlet.invokeOperation(WebServiceServlet.java:343)
    at weblogic.webservice.server.servlet.ServletBase.handleGet(ServletBase.java:266)
    at weblogic.webservice.server.servlet.ServletBase.doGet(ServletBase.java:158)
    at weblogic.webservice.server.servlet.WebServiceServlet.doGet(WebServiceServlet.java:254)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    >
    <Apr 18, 2006 5:54:57 AM CDT> <Info> <WebService> <BEA-220094> <An IOException was thrown trying to access the WSDL at the given URL.>
    <Apr 18, 2006 5:54:57 AM CDT> <Info> <WebService> <BEA-220034> <A stack trace associated with message 220094 follows:
    java.io.FileNotFoundException: Response: '403: Forbidden' for url: 'http://XXX.XXX.XX.XX:80/eventws/EventManagementService?WSDL'
    at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:425)
    at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:28)
    at weblogic.webservice.tools.wsdlp.DefinitionFactory.createDefinition(DefinitionFactory.java:126)
    at weblogic.webservice.tools.wsdlp.WSDLParser.<init>(WSDLParser.java:76)
    at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:108)
    at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:84)
    at weblogic.webservice.server.servlet.ServletBase.invokeOperation(ServletBase.java:295)
    at weblogic.webservice.server.servlet.WebServiceServlet.invokeOperation(WebServiceServlet.java:343)
    at weblogic.webservice.server.servlet.ServletBase.handleGet(ServletBase.java:266)
    at weblogic.webservice.server.servlet.ServletBase.doGet(ServletBase.java:158)
    at weblogic.webservice.server.servlet.WebServiceServlet.doGet(WebServiceServlet.java:254)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)<pre></pre><pre></pre>urlurl

    Hi Francois,
    The JAR file generated by the <clientgen> Ant task, has a static WSDL inside it.
    To get your JAX-RPC client to use it, write code that looks like this:
    MyService_Impl service = null;
    MyServicePort port = null;
    try
    // There are two constructors for every XXX_Impl class.
    // The one that accepts a wsdlURL (as a String) will
    // request the WSDL from the service provider. The
    // no-arg one will just use the statis WSDL in the
    // client.jar generated by the <clientgen> Ant task.
    service = new MyService_Impl();
    port = service.getMyServicePort();
    MyObject response = port.myServiceOperation();
    Again, this will cause the WLS client-side JAX-RPC classes, in the webserviceclient.jar,
    to use the static WSDL (in the client.jar generated by the <clientgen> Ant task)
    to invoke the target web service. It will not send a request to the target web
    service to retrieve it's WSDL, because it already has it.
    Regards,
    Mike Wooten
    Francois Staes <[email protected]> wrote:
    >
    Hello,
    I'm trying to access some simple web services which are implemented using
    some Perl module (don't ask ....).
    After I've gotten their WSDL file, I can successfully generate stubs
    using
    the clientgen ant task.
    However, when I try to access the webservice from within my EJB's, I
    get the
    following error message:
    An IOException was thrown trying to access the WSDL at the given URL.
    java.io.FileNotFoundException: Response: '411: Length Required' for url:
    'http://petest01:8082/cgi-bin/WebStore.cgi'
    It seems as if the perl SOAP implementation doesn't allow me to check
    their
    WSDL file. Just sending the SOAP POST messages works fine.
    I explicitly specified the 'saveWSDL' option to the clientgen task, but
    it
    still tries to access the WSDL file at runtime. Any way to resolv this
    issue?
    Regards,
    Francois Staes.

  • Problem while sending/Receiving request using the HttpURLConnection obj

    Hi,
    We are facing the problem while passing the request in Weblogic.
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    Currently we are migrating 2 applications to WebLogic. Application1 to application2 request should pass.
    Below is some example we tried:
    "When we send a request to our code using the SSOAdaptor code (which handles the request/session in our application) which is on the SunOne server the request parameters are received by our code successfully. And also in Create User Functionality of application1 we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass."
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues.
    Where as when the request is sent from WebLogic to WebLogic the request parameters are missing some how.
    Is there any issue in Weblogic? Please helpus on this.
    Thanks,
    Nagesh
    Edited by: user9307541 on Mar 15, 2010 5:08 AM

    Hi,
    Please find below scenario for testing.
    We have tested the SSOAdaptor code (it is the fucntion name which will send the data from source) locally by hittiing the WPS adaptor URL in a Java client program(TestRequest.java) and the request parameters were reaching the WPS Adapter successfully.
    Then we have written two test servlets to test the communication between SSOAdaptor(TestServlet.java) and WPS adaptor(WPSServlet.java).
    Functionality of TestSevlet: It is sending a request to WPSServelt similar to the way we are doing it in SSOAdaptor.
    Functionality of WPSServlet: It will receive the request parameters and write the parameter Map to console.
    We have deployed and these two servlets(in a single webapplication) on Tomcat server and the request parameters are reaching the WPSServlet successfully.
    Output on Tomcat server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{TypeAcc=[Ljava.lang.String;@14e3f41, ServiceName=[Ljava.lang.String;@1acd47, GMEPortalUserID=[Ljava.lang.String;@19b04e2, UserID=[Ljava.lang.String;@5dcec6, Country=[Ljava.lang.String;@b25b9d}
    after sending request
    After this we have deployed these two servlets (with in a single webapplication) on the Weblogic server in Dev machine(path: /apps/usmport/domains/usmport/servers/usmport_admin/upload/ssoAdaptor/WEB-INF/classes/com/gm/gmeportal/security/adaptor) and
    now the request parameters are not reaching the WPSServlet.
    Output on Weblogic Server:
    before sending request
    **********************Inside WPS Servlet -- the request Map is:{}
    after sending request
    Looks like there is some problem with Weblogic while sending/Receiving the request using the HttpURLConnection object.
    When we send a request to WPSAdaptor using the Old SSOAdaptor code which is on the SunOne server the request parameters are received by WPS successfully. And also in Create User Functionality of Portal we are sending a request to webpass(which is on Sunone Server) using the HttpURLConnection object and the SOAP request is received successfully by the Webpass.
    Looks like when we send request (using HttpURLConnection) from a server other than Weblogic to a servlet in a Weblogic the request parameters are received with out issues. Where as when the request is sent from weblogic to weblogic the request parameters are missing some how.
    Please find below javs source code used to test this:
    TestRequest.java
    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class TestRequest {
         * @param args
         public static void main(String[] args) throws Exception{
              // TODO Auto-generated method stub
              excutePost("http://localhost:8080/Testing/TestServlet", "GMEPortalUserID=captest.wss@it0555&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
              //System.out.println("********** Now the request is from SSO *****************");
              //excuteGet("http://10.156.0.173:7013/channel21/wpsadapter", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
         public static String excutePost(String targetURL, String urlParameters)
         URL url;
         HttpURLConnection connection = null;
         try {
         //Create connection
         url = new URL(targetURL);
         connection = (HttpURLConnection)url.openConnection();
         connection.setRequestMethod("POST");
         connection.setRequestProperty("Content-Type",
         "application/x-www-form-urlencoded");
         connection.setRequestProperty("Content-Length", "" +
         Integer.toString(urlParameters.getBytes().length));
         connection.setRequestProperty("Content-Language", "en-US");
         connection.setUseCaches (false);
         connection.setDoInput(true);
         connection.setDoOutput(true);
         //Send request
         DataOutputStream wr = new DataOutputStream (
         connection.getOutputStream ());
         wr.writeBytes (urlParameters);
         wr.flush ();
         wr.close ();
         //Get Response     
         InputStream is = connection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(connection != null) {
         connection.disconnect();
         public static String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    TestServlet.java
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class TestServlet
    public class TestServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * Default constructor.
    public TestServlet() {
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doPost(request,response);
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              //System.out.println("********************** the request Map is:" + request.getParameterMap());
              try {
                   System.out.println("before sending request");
                   excuteGet("http://localhost:7003/ssoAdaptor/WPSServlet", "GMEPortalUserID=captest.wss@it0554&UserID=bl1133&Country=it&TypeAcc=256&ServiceName=Logon");
                   System.out.println("after sending request");
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public String excuteGet(String targetURL, String urlParameters) throws Exception
              URL url = new URL(targetURL);
              HttpURLConnection httpurlconnection =
                   (HttpURLConnection) url.openConnection();
              /*httpurlconnection.setRequestProperty(
                   "cookie",
                   constructRequestParams(httpservletrequest.getCookies()));*/
              httpurlconnection.setDoOutput(true);
              httpurlconnection.setDoInput(true);
              httpurlconnection.setRequestProperty(
                   "Content-length",
                   String.valueOf(urlParameters.length()));
              OutputStream outputstream = httpurlconnection.getOutputStream();
              outputstream.write(urlParameters.getBytes());
              outputstream.flush();
              //Get Response     
              try{
         InputStream is = httpurlconnection.getInputStream();
         BufferedReader rd = new BufferedReader(new InputStreamReader(is));
         String line;
         StringBuffer response = new StringBuffer();
         while((line = rd.readLine()) != null) {
         response.append(line);
         response.append('\r');
         rd.close();
         //System.out.println("Response from SSO is:" + response);
         return response.toString();
         } catch (Exception e) {
         e.printStackTrace();
         return null;
         } finally {
         if(httpurlconnection != null) {
              httpurlconnection.disconnect();
    WPSServlet.java
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    * Servlet implementation class WPSServlet
    public class WPSServlet extends HttpServlet {
         private static final long serialVersionUID = 1L;
    * @see HttpServlet#HttpServlet()
    public WPSServlet() {
    super();
    // TODO Auto-generated constructor stub
         * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              System.out.println("**********************Inside WPS Servlet -- the request Map is:" + request.getParameterMap());
         * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              doGet(request,response);
    Thanks,
    Nagesh

  • Java.io.IOException: Server returned HTTP response code: 500 for URL:

    Hi,
    I am using java.net.URLConnection to invoke servlet which uses oracle.xml.sql.dml.OracleXMLSave for dml operations.
    I am facing below exception.
    09/05/26 17:47:50 java.io.IOException: Server returned HTTP response code: 500 for URL: http://xxx.com/servlets/com.xxx.qu.XMLDocPostOracleInsert
    09/05/26 17:47:50 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpConnection.java:)
    09/05/26 17:47:50 at com.xxx.util.http.HTTPRequester.makePostRequest(HTTPRequester.java:)
    09/05/26 17:47:50 at com.xxx.qu.PostReceiver.doPost(PostReceiver.java:145)
    09/05/26 17:47:50 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    09/05/26 17:47:50 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    09/05/26 17:47:50 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:810)
    09/05/26 17:47:50 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
    09/05/26 17:47:50 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
    09/05/26 17:47:50 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
    09/05/26 17:47:50 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
    09/05/26 17:47:50 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    09/05/26 17:47:50 at java.lang.Thread.run(Thread.java:534)
    The oraclexmlsave operations are with in try-catch block as shown below, but its not getting caught there(Donnno Whyy????).Instead its giving
    exception at HttpURLConnection.getInputStream
    try{
    System.out.println("entered try :1");
    String Query="SELECT * from global_name";
    Statement CntStmt=con.createStatement();
    ResultSet rsEmailAlertQuery=CntStmt.executeQuery(Query);
    while(rsEmailAlertQuery.next()){
    System.out.println(rsEmailAlertQuery.getString(1));
    OracleXMLSave oxs = new OracleXMLSave(con,insertObject);
    System.out.println("MI B: ");
    oxs.setRowTag("row");
    oxs.setIgnoreCase(true);
    int rowsInserted = oxs.insertXML(xd);
    System.out.println("MI C: ");
    out.println("<success>TRUE</success>");
    con.commit();
    System.out.println("MI D: ");
    catch(OracleXMLSQLException e){
    System.out.println("OracleXMLSQLException");
    e.printStackTrace();
    catch(SQLException e){
    System.out.println("SQLException");
    e.printStackTrace();
    catch(Exception e){
    System.out.println("Exception");
    e.printStackTrace();
    Normal jdbc queries(rsEmailAlertQuery) are working properly.The problem is only with OracleXMLSave.
    Any help would be greatfull.
    Edited by: suryaraj on 29-May-2009 06:45

    Hi,
    May be you can get the description of the error on the server log of the server running on ip:url
    -Priyanka

  • Host name wrong IOexception in HTTPS

    Hi everyone,
    my little HTTPS client works on www.sun.com, www.microsoft.com ect. but if i set it to access localhost (or "troy" which is the name of my machine), it gives me the following exception:
    bash-2.05b$ java -Djavax.net.ssl.trustStore=key1 HTTPSclient
    java.io.IOException: HTTPS hostname wrong: should be <localhost>
    at sun.net.www.protocol.https.HttpsClient.b(DashoA6275)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(DashoA6275)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(DashoA6275)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:617)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(DashoA6275)
    at HTTPSclient.main(HTTPSclient.java:54)
    note, i have already imported my apache's certificate into my java's trust list (the key1 keystore)
    is it something do with the HostnameVerifier?
    here is some codes in my client:
    url = new URL ("https://localhost");
              cnx= (HttpsURLConnection)url.openConnection();
              InputStream input= cnx.getInputStream();
              cnx.setDefaultHostnameVerifier(null) ;
    Thank you very much.

    Hi
    I had the same problem, just fixed it.Check the CN name in your certificate,it should be localhost or the server name from where you are hosting.
    e.g server name : localhost
    your CN name in certificate should be localhost
    Hope this will solve your problem Good Luck Pal!
    CT

  • HttpURLConnection -- getting error 502 passing ftp url  w embedded password

    I am connecting to http proxy server which supports cern ftp.
    I specify the -DftpProxySet command line options to point java to the http proxy.
    I specify a ftp url like following and it works OK:
    ftp://machine.company.com/readme.txt
    it works fine.
    But when I change the ftp server to require password and pass ftp url such as
    ftp://user:[email protected]/readme.txt. , it fails.
    It works OK when I type above password ftp Url manually into the IE browser that is pointing to same http proxy the java is using.
    Error:
    java.io.IOException: Server returned HTTP response code: 502 for URL: ftp://user:[email protected]/readme.txt
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:562) at com.mycompany....Line 300
    Line 300:
    InputStream stream = connection.getInputStream();

    Hi, I have exactly the same problem!
    Could you solve it?
    Regards, Markus

  • HttpURLConnection throws a FileNotFound exception

    Hi Everybody,
    I want to post the data to a remote servlet using HttpURLConnection.
    But it throws a FileNotFound exception. Pls send me the solution.
    My code is
    First Servlet:
    ==============
    import java.io.*;
    import java.net.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Test extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    response.setContentType("text/html");
              URL url = new URL("http://node_18:8080/examples/servlet/HelloWorldExample1");
              HttpURLConnection conn = (HttpURLConnection) url.openConnection();
              conn.setRequestMethod("POST");
              //HttpURLConnection.setFollowRedirects(true);
              conn.setUseCaches(false);
              conn.setDoOutput(true);
              conn.setDoInput(true);
              String postData = "name=value&othername=value";
              String lengthString = String.valueOf(postData.length());
              conn.setRequestProperty("Content-Length", lengthString);
              conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
              Writer out = new OutputStreamWriter(conn.getOutputStream());
              out.write(postData);
              out.close();
              PrintWriter out1 = response.getWriter();
              BufferedReader in =
              new BufferedReader(new InputStreamReader(conn.getInputStream()));
              String line = null;
              while (null != (line = in.readLine()))
              out1.println(line);
              in.close();
              out1.close();
    Second Servlet:
    ================
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorldExample1 extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String name = request.getParameter("name");
    String othername = request.getParameter("othername");
    System.out.println("name = "+name+" othername = "+othername);
    out.println("<html>");
    out.println("<head>");
         out.println("<title> Test </title>");
    out.println("</head>");
    out.println("<body bgcolor=\"white\">");
         out.println("Test");
    out.println("</body>");
    out.println("</html>");
    public void destroy() {
         System.out.println("Servlet Destroyed");
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
         doPost(request,
    response);
    Error:
    =======
    java.io.FileNotFoundException: http://node_18:8080/examples/servlet/HelloWorldExample1
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:574)
         at Test.doGet(Test.java:37)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:471)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:623)
         at java.lang.Thread.run(Thread.java:484)

    Hi p200002,
    I call doPost method in doPost in the second servlet. It will be
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
         doGet(request,
    response);
    }

  • HttpURLConnection not connecting to all sites

    Hi folks,
    I have a small class which takes a URL as commandline input and outputs the HTML to stdout:
    import java.net.*;
    import java.io.*;
    public class URLReader {
        public static void main(String[] args) throws Exception {
         URL url = new URL(args[0]);
         HttpURLConnection conn = (HttpURLConnection) url.openConnection();
         conn.setDoInput(true);
         conn.setDoOutput(true);
         OutputStream os = conn.getOutputStream(); // Line 1
         os.close(); // Line 2
         conn.connect(); // Line 3
         BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null) {
              System.out.println(inputLine);
         in.close();
    }If I try this:
    java URLReader http://www.asp.com
    I get the error:
    =====
    Exception in thread "main" java.io.IOException: Server returned HTTP response code: 405 for URL: http://www.asp.com
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:575)
    at URLReader.main(URLReader.java:18)
    =====
    But, if I comment out the lines marked as Line 1, Line 2 and Line 3 it works fine and returns me the HTML.
    Why would opening the Output Stream cause this?
    Thanks in advance!
    Musafir

    Thanks for the response - sort of what I was guessing.
    But, to me this behaviour is a bit counter-intuitive.
    If I am making a GET request (in the request header),
    then the request body should simply be ignored. To
    disallow it altogether and produce errors is, IMHO,
    undesirable behaviour.Some people are more paranoid that others and like to lock things uo tight.
    What is more, it works for a very large number of
    sites - www.bea.com, www.slashdot.org. It even works
    for www.microsoft.com and www.msdn.microsoft.com!!Again it depends on the people running the site.
    As a follow-up, what would I be doing in my Server
    Side App to disallow request bodies when making a GET
    request? Is it a Web Server setting?It can be done in the web server configuration or handled with in the code.
    Thanks for the tip! Warm regards,
    Musafir

  • Oc4jDcmServlet  : java.io.IOException: Error writing to server

    I've been using the following ant task to do a remote deployment to an OC4J container :
    <tasks>
    <java jar="../../../../../MAVEN-WORK/portal-lib/oc4j_remote_deploy.jar" fork="yes" maxmemory ="512m">
    <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>
    <arg value="http://wblv-ep-sp05:1824/Oc4jDcmServletAPI/"/>
    <arg value="ias_admin"/>
    <arg value="admin_dev3"/>
    <arg value="redeploy"/>
    <arg value="/app/oracle/product/oc4jext10.1.2-d3"/>
    <arg value="../portal-ear/target/portal.ear"/>
    <arg value="portal"/>
    <arg value="OC4J_portal"/>
    </java>
    </tasks>
    This has worked before , but I'm suddenly getting error when trying to run it .The error message and stack trace are shown below :
    [INFO] Executing tasks
    [java] Initializing log
    [java] Servlet interface for OC4J DCM commands
    [java] Command timeout defined at 600 seconds
    [java] Executing DCM command...
    [java] Executing command redeploy /app/oracle/product/oc4jext10.1.2-d3 ../e
    portal-ear/target/ePortalep2x-QA-V-02_00_5-20070220.ear eportal OC4J_Eportal
    [java] Command = REDEPLOY
    [java] Reading application's ear file
    [java] Ear file was successfully read
    [java] Opening connection to Oc4jDcmServlet
    [java] Setting userName to ias_admin
    [java] Sending command to DCM servlet
    [java] **** Could not check HTTP response code
    [java] ** Thread[main,5,main] ** Sun Feb 25 20:47:34 CAT 2007 ** ** EXCEP
    TION: java.io.IOException: Error writing to server
    [java] java.io.IOException: Error writing to server
    [java] at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Htt
    pURLConnection.java:416)
    [java] at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Htt
    pURLConnection.java:428)
    [java] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Ht
    tpURLConnection.java:934)
    [java] at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.
    java:367)
    [java] at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.isHttpResponseO
    k(Unknown Source)
    [java] at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.sendCommand(Unk
    nown Source)
    [java] at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.execute(Unknow
    n Source)
    [java] at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.redeployApplic
    ation(Unknown Source)
    [java] at oracle.j2ee.tools.remote_deploy.Oc4jDcmMain.main(Oc4jDcmMain.
    java:63)
    [java] #### HTTP response is NOT ok
    [java] Closing connection to Oc4jDcmServlet
    [java] #### DCM command did not complete successfully (-1)
    [java] #### HTTP return code was -1
    [java] Java Result: -1
    [INFO] Executed tasks
    It seems to stall at the "Sending command to DCM servlet" stage , then fails.
    Does the DCM servlet write out logs that I can look at?Where is the Oc4jDcmServlet.ear located in an OC4J container directory hierarchy?How do I redeploy the Oc4jDcmServlet.ear ?
    This was working a few hours ago as seen here in my previous logs (and I do not understand what could have gone wrong) :
    ** Thread[main,5,main] ** Thu Feb 22 14:50:39 CAT 2007 ** Initializing log
    ** Thread[main,5,main] ** Thu Feb 22 14:50:39 CAT 2007 ** Servlet interface for OC4J DCM commands
    ** Thread[main,5,main] ** Thu Feb 22 14:50:39 CAT 2007 ** Command timeout defined at 600 seconds
    ** Thread[main,5,main] ** Thu Feb 22 14:50:39 CAT 2007 ** Executing command redeploy /app/oracle/product/oc4jext10.1.2-d3 ../portal-ear/target/portal.ear portal OC4J_portal
    ** Thread[main,5,main] ** Thu Feb 22 14:50:39 CAT 2007 ** Command = REDEPLOY
    ** Thread[main,5,main] ** Thu Feb 22 14:50:39 CAT 2007 ** Reading application's ear file
    ** Thread[main,5,main] ** Thu Feb 22 14:50:45 CAT 2007 ** Ear file was successfully read
    ** Thread[main,5,main] ** Thu Feb 22 14:50:45 CAT 2007 ** Opening connection to Oc4jDcmServlet
    ** Thread[main,5,main] ** Thu Feb 22 14:50:45 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:50:45 CAT 2007 ** Sending command to DCM servlet
    ** Thread[main,5,main] ** Thu Feb 22 14:50:50 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:50:50 CAT 2007 ** Command was successfully sent to Oc4jDcmServlet
    ** Thread[main,5,main] ** Thu Feb 22 14:50:50 CAT 2007 ** Receiving session id from servlet to check command status
    ** Thread[main,5,main] ** Thu Feb 22 14:50:50 CAT 2007 ** Session id = 0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:50:50 CAT 2007 ** Please, wait for command to finish...
    ** Thread[main,5,main] ** Thu Feb 22 14:51:00 CAT 2007 ** Checking command status...
    ** Thread[main,5,main] ** Thu Feb 22 14:51:00 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:51:00 CAT 2007 ** Setting Cookie to JSESSIONID=0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:51:00 CAT 2007 ** Checking command status
    ** Thread[main,5,main] ** Thu Feb 22 14:51:00 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:51:00 CAT 2007 ** Command has not finished yet
    ** Thread[main,5,main] ** Thu Feb 22 14:51:10 CAT 2007 ** Checking command status...
    ** Thread[main,5,main] ** Thu Feb 22 14:51:10 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:51:10 CAT 2007 ** Setting Cookie to JSESSIONID=0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:51:10 CAT 2007 ** Checking command status
    ** Thread[main,5,main] ** Thu Feb 22 14:51:10 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:51:10 CAT 2007 ** Command has not finished yet
    ** Thread[main,5,main] ** Thu Feb 22 14:51:20 CAT 2007 ** Checking command status...
    ** Thread[main,5,main] ** Thu Feb 22 14:51:20 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:51:20 CAT 2007 ** Setting Cookie to JSESSIONID=0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:51:20 CAT 2007 ** Checking command status
    ** Thread[main,5,main] ** Thu Feb 22 14:51:20 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:51:20 CAT 2007 ** Command has not finished yet
    ** Thread[main,5,main] ** Thu Feb 22 14:51:30 CAT 2007 ** Checking command status...
    ** Thread[main,5,main] ** Thu Feb 22 14:51:30 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:51:30 CAT 2007 ** Setting Cookie to JSESSIONID=0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:51:30 CAT 2007 ** Checking command status
    ** Thread[main,5,main] ** Thu Feb 22 14:51:30 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:51:30 CAT 2007 ** Command has not finished yet
    ** Thread[main,5,main] ** Thu Feb 22 14:51:40 CAT 2007 ** Checking command status...
    ** Thread[main,5,main] ** Thu Feb 22 14:51:40 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:51:40 CAT 2007 ** Setting Cookie to JSESSIONID=0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:51:40 CAT 2007 ** Checking command status
    ** Thread[main,5,main] ** Thu Feb 22 14:51:40 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:51:40 CAT 2007 ** Command has not finished yet
    ** Thread[main,5,main] ** Thu Feb 22 14:51:50 CAT 2007 ** Checking command status...
    ** Thread[main,5,main] ** Thu Feb 22 14:51:50 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:51:50 CAT 2007 ** Setting Cookie to JSESSIONID=0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:51:50 CAT 2007 ** Checking command status
    ** Thread[main,5,main] ** Thu Feb 22 14:51:50 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:51:50 CAT 2007 ** Command has not finished yet
    ** Thread[main,5,main] ** Thu Feb 22 14:52:00 CAT 2007 ** Checking command status...
    ** Thread[main,5,main] ** Thu Feb 22 14:52:00 CAT 2007 ** Setting userName to ias_admin
    ** Thread[main,5,main] ** Thu Feb 22 14:52:00 CAT 2007 ** Setting Cookie to JSESSIONID=0afb65197201792b582df0d486285eef6aa19c1ab64
    ** Thread[main,5,main] ** Thu Feb 22 14:52:00 CAT 2007 ** Checking command status
    ** Thread[main,5,main] ** Thu Feb 22 14:52:00 CAT 2007 ** HTTP response code = 200, HTTP response msg = OK
    ** Thread[main,5,main] ** Thu Feb 22 14:52:00 CAT 2007 ** Command has finished

    I looked at the log.xml file under the dcm/logs/daemon_logs directory and saw this :
    <MESSAGE>
    <HEADER>
    <TSTZ_ORIGINATING>2007-02-26T08:49:13.203+02:00</TSTZ_ORIGINATING>
    <COMPONENT_ID>DCM</COMPONENT_ID>
    <MSG_TYPE TYPE="ERROR"></MSG_TYPE>
    <MSG_LEVEL>1</MSG_LEVEL>
    <HOST_ID>wblv-ep-sp05</HOST_ID>
    <HOST_NWADDR>10.251.101.25</HOST_NWADDR>
    <MODULE_ID>oracle/defaultLogger/ExceptionLogger</MODULE_ID>
    <THREAD_ID>Deamon Worker for TaskMaster of iAS instance at: /app/oracle/product/oc4jext10.1.2-d3 JVM Id = 1b09468.110df14be01.-8000</THREAD_ID>
    <USER_ID>oracle</USER_ID>
    </HEADER>
    <CORRELATION_DATA>
    <EXEC_CONTEXT_ID><UNIQUE_ID>10.251.101.25:47620:1172472553186:2846</UNIQUE_ID><SEQ>0</SEQ></EXEC_CONTEXT_ID>
    </CORRELATION_DATA>
    <PAYLOAD>
    <MSG_TEXT>principals specified in application is not a valid path: /app/oracle/product/oc4jext10.1.2-d3/j2ee/home/config/../application-deployments/ADFBCManager/principals.xml</MSG_TEXT>
    </PAYLOAD>
    </MESSAGE>
    The same MSG_TEXT appears in the log every time i had a failed deploy.

Maybe you are looking for

  • Word property with multiple lines

    Good Morning, I have a Document Library with an Word template, I fill some properties of the library so I can put this properties in the template. I am trying to write a line break, Any idea? Thanks.

  • Outgoing Payment Previous & Next Entry

    Dear All , if  i  searching the Transaction in Outgoing Payment Screen frequently  using next and previous button , SAP getting struck and closed automatically. How to solve this problem Thanks & Regards Madhu

  • How to export Schema to a cvs file?

    I want to know whether or not there is a tool that exports schema to a csv file?

  • Problems with the JVM versions

    Hi I am new here I was wondering if someone can help me out here I am having proplems with the versions of java. I have downloaded the lastest version and this is what i got when i verifyed my installation. Can someone help me? I have copied and past

  • Problems with SB X-fi Audio, fast help requi

    Hey! i've got an BIG problem with my Soundblaster X-Fi Audio. I can hear any sound that is played on the computer, so there is no problem there, i have installed it correctly and deactivated my on-board soundcard. But sometimes, either when i'm produ