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.

Similar Messages

  • JarURL.openStream() throws *IOException: no entry name specified*

    <pre>
    I have some code (supplied below) which tries to read contents of a resource
    referred by a URL.
    public class URLTest {
    public static void main(String... args) throws Exception {
    URL u = new URL(args[0]);
    InputStream is = u.openStream();
    // more code goes here:
    If you create a jar file in /tmp/b.jar and run this program as shown below:
    (If your shell treats ! as a special char, then you need to use escape char \ before it)
    java pkg.URLTest <b>jar:file:/tmp/b.jar!/</b>
    it produces the following exception:
    Exception in thread "main" java.io.IOException: no entry name specified
    at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:131)
    at java.net.URL.openStream(URL.java:1007)
    at pkg.URLTest.main(URLTest.java:20)
    But, if you pass the argument as jar:file:/tmp/b.jar!/A.class then it opens a stream
    that points to A.class which is embedded inside b.jar.
    My question is, what is the motivation behind not allowing user to open a stream to
    jar:file:/tmp/b.jar!/ which according to the javadocs of JarURLConnection
    http://java.sun.com/j2se/1.5.0/docs/api/java/net/JarURLConnection.html
    represents a JAR File?
    Thanks,
    Sahoo
    </pre>

    I just also came across this. I don't know the motivation behind it. But it is certainly deliberate.
    This is the source code for JarURLConnection.getInputStream.
    public InputStream getInputStream() throws IOException {
         connect();
         InputStream result = null;
         if (entryName == null) {
              throw new IOException("no entry name specified");
         } else {
              if (jarEntry == null) {
                   throw new FileNotFoundException("JAR entry " + entryName +
                        " not found in " +
                        jarFile.getName());
              result = new JarURLInputStream (jarFile.getInputStream(jarEntry));
         return result;
    }So it will only let you get an InputStream to a file inside the Jar file, not the Jar file itself.
    If you want to do that, then rather than using InputStreams you want to use the JarURLConnection class. My example below shows you how to get at the JarFile and its contents, JarEntry objects,
    URL u = new URL("/tmp/b.jar!/");
    JarURLConnection juc = (JarURLConnection)u.openConnection();
    JarFile jf = juc.getJarFile();
    System.out.println("JarFile: " + jf.getName());
    Enumeration<JarEntry> entries = jf.entries();
    for(JarEntry je = entries.nextElement(); entries.hasMoreElements(); je = entries.nextElement())
         System.out.println("\tJarEntry: " + je.getName());
    }

  • DOMparser throws IOException when encounters Hungarian Characters

    Hoi!
    I wrote a piece of code that extracts some
    information from an XML document into a vector of Java classes, using the oracle.xml.parser.v2.DOMParser.
    And it worked. Or seemed to work...
    But when I put some articles in the XML file
    in Hungarian, the parser threw IOException.
    If I remplace the Hungarian characters to
    English "equivalents" a -> a etc., it works.
    I don't know. If XML is made up of Unicode characters, what's the problem with it?
    (The hex code of a was E1 in my text editor,
    as I'm using Win NT :(. )
    can I modify the xml prolog somehow?
    I'd rather not write a conversion program
    from a text file to another.
    Any ideas?
    and here's the code:
    DOMParser theParser = new DOMParser();
    XMLStreamToParse = XMLes.class.getResourceAsStream(xmlDocPath);
    theParser.setValidationMode(false);
    try{
    theParser.parse( XMLStreamToParse );
    //this throws IOException
    null

    What are you using as your test client?The test client is WebStone 1.0. WebStone always downloads the whole response, and reports the size of the response in bytes. From this I can see that when the IO exception occurs, webstone is unable to read the whole response, as it reports a smaller size.
    So, I do not think the problem is that the client has prematurely aborted its download. WebStone doesn't work that way. I think something has gone awry on the server side, and this worries me.

  • [Windows] file.url throw error when application executable in root directory

    Here is the bugbase ticked: Bug#3940278 - [Windows] file.url throw error when application executable in root directory
    If you launch AIR application packaged as bundle from root directory and try to get url property of any file you get IllegalOperationError.
    No matter what file url property you try to get.
    It's a big problem when you distribute your application on CD disks or flash drive.
    I'd like to ask everyone affected by this issue to take a minute and vote for the following bug.
    Thanks.

    I checked all deployment descriptions and there are no references to t3://localhost:7001. Few months back, I had the complete clustering setup working on 2 machines and now when I deploy my application on same configuration, it fails with t3://localhost:7001 unreachable error. I created a new cluster configuration on one machine with 2 managed server and it deploys fine. Can not figure out what has changed ?

  • SocketChannel.write() throws IOException instead of returning 0

    I would like your opinion.
    When a send buffer is full in the OS, should a channel's write()
    return 0, or throw an exception? If an exception, should it be the
    same exception (IOException) thrown when truly exceptional events
    happen (e.g, a connection drop)?
    On Win32, SocketChannel.write() internally calls WSASend(). When
    WSASend() returns WSAEWOULDBLOCK, write() throws IOException. I
    think it should return zero instead, or at least throw an exception
    that can be distinguished easily (by other than parsing the
    IOException.getMessage())
    Should I submit a bug?
    Thanks,
    Juan

    The java doc for write() says it should return zero. If you have a simple test case that demonstrates the behavior you describe and it is not already in the bug database, then yes. You should file the bug report.

  • Throws IOException

    What is a best way to write throwing IOException here?
    Can I write try-catch, and after "catch" throw it?
    Is this right?
    I have no idea how to do it with if-clause.
    /** Writes the given apartment data in the file. If the file already
    exists, the old contents are overwritten.
    Parameters:
    apartment - the apartment to be written in the file
    Throws:
    IOException - if other problems arose when handling the file (e.g. the
    file could not be written) */
            public Appartment writeAppartment(Appartment appartment)
                  throws IOException {
                 try {
                    writeStream = new FileOutputStream(filepath);
                    objectStream = new ObjectOutputStream(objectStream);
                    objectStream.writeObject(appartment);
                 } catch (Exception e) {
                   String message ="Writing to file "+filepath+ " failed.";
                   throw new IOException(message);
    }

    Since your method is defined as "throws IOException", why not just get
    rid of the whole try/catch block. Let the caller of writeAppartment
    catch it. You don't seem to be doing anything special with the
    exception when your throwing it, like throwing a custom one, so just
    let java throw it. Plus, what if there is a NullPointerException...it
    would be thrown as an IOException?I see, I haven't understood that when the method is defined as
    "throws IOException", it throws it "automatically".
    So I haven't to do anything.
    But when I call this "throws-method" I have to catch the Exception or
    throw it forward.
    Is that right???
    was meant to be:
    objectStream = new ObjectOutputStream(writeStream);jep, sorry there was an error in that line.

  • Log API: StreamHandler.flush() throws IOException ?

    For some network error reason, my logging stopped working and i noticed this exception in the console:
    java.util.logging.ErrorManager: 2
    java.io.IOException: The specified network name is no longer available
            at java.io.FileOutputStream.writeBytes(Native Method)
            at java.io.FileOutputStream.write(Unknown Source)
            at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(Unknown Source)
            at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(Unknown Source)
            at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(Unknown Source)
            at sun.nio.cs.StreamEncoder.flush(Unknown Source)
            at java.io.OutputStreamWriter.flush(Unknown Source)
            at java.util.logging.StreamHandler.flush(Unknown Source)
            at de.icp.logging.RollingFileHandler.publish(Unknown Source)I looked into the javadoc of StreamHandler.flush() and can't find any documented Exception that is thrown. As IOException is not an unchecked exception, this seems to be a javadoc bug, right?
    My "RollingFileHandler extends StreamHandler and my publish() looks like this:
         * Overwrites super.
        public synchronized void publish(LogRecord record) {
            if (!isLoggable(record)) {
                return;
            //check if we need to rotate
            if (System.currentTimeMillis() >= nextCycle) { //next cycle?
                role();
            super.publish(record);
            flush(); //throws IOException ??????
        }//publish()

    Hm ... i think overwriting reportError() is useful:
         * Overwrites super.
         * Reopen log file in case of an error.
        protected void reportError(String msg, Exception ex, int code) {
            super.reportError(msg, ex, code); //standard behaviour of Handler
           //on logging error, try to reopen the logfile:
            openFile();
            LogRecord record = new LogRecord(Level.WARNING, "Log file re-opened due to error:");
            record.setThrown(ex);
            publish(record);
        }//reportError()

  • Model no n259tx trying to refresh the windows 8.1 throwing an error

    Hi,
    Am having an brand new laptop n259tx with pre installed Windows 8.1. When I am trying to refresh the windows it is throwing an error saying. "windows can not complete the installation. To install windows on this computer, restart the installation" but I haven't done anything, I just click only on the refresh button.
    So please kindly help me, because am hang up with my important work.
    Thanks in advance, for your kind support.

    If you are using Windows 8.1 Refresh, then that means you do not mind having everything on the disk deleted.
     I suggest that you use the recovery media that you should have created by this time instead of Windows Refresh. That will put your notebook back in the state that is was when it was delivered to you. 
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • Serversocket.close() not causing accept() to throw IOException

    My problem is quiet simple. The follow code does not display the string "accept() failed or interrupted..." on the console. Which I believe is part of the Java specification. The code DOES work on a RedHat Linux machine running Java 1.4.2 and 1.5.0, and it works on a machine with Windows XP and 1.4.2, but it does not work on my SuSE Linux machine with 1.4.2, 1.5.0, or any other 1.4.x jvm I've tried.
    What could be wrong?
    import java.net.*;
    import java.io.*;
    class Example5 extends Thread {
      volatile boolean stop = false;
      volatile ServerSocket socket;
      public static void main( String args[] ) throws Exception {
        Example5 thread = new Example5();
       System.out.println( "Starting thread..." );
       thread.start();
       Thread.sleep( 3000 );
       System.out.println( "Asking thread to stop..." );
       thread.stop = true;
       thread.socket.close();
       Thread.sleep( 3000 );
       System.out.println( "Stopping application..." );
       System.exit( 0 );
      public void run() {
        try {
          socket = new ServerSocket(7856);
        } catch ( IOException e ) {
         System.out.println( "Could not create the socket..." );
          return;
        while ( !stop ) {
         System.out.println( "Waiting for connection..." );
          try {
           Socket sock = socket.accept();
          } catch ( IOException e ) {
          System.out.println( "accept() failed or interrupted..." );
       System.out.println( "Thread exiting under request..." );
    }

    I actually already have a work around, we have set the SoTimeout for our ServerSockets. I also have this problem on regular Socket's as well, and have set their SoTimeout as well.
    On a somewhat related note, I'm getting a Hotspot Virtual Machine exception when I try and send some data over one of these connections. Since none of my coworkers have this problem, I assume it has something to do with my computer.
    # An unexpected error has been detected by HotSpot Virtual Machine:
    # SIGSEGV (0xb) at pc=0x403afd0f, pid=23569, tid=1075155072
    # Java VM: Java HotSpot(TM) Client VM (1.5.0_01-b08 mixed mode, sharing)
    # Problematic frame:
    # V [libjvm.so+0x255d0f]
    --------------- T H R E A D ---------------
    Current thread (0x0807fed0): JavaThread "main" [_thread_in_native, id=23569]
    siginfo:si_signo=11, si_errno=0, si_code=0, si_addr=0x00000000
    Registers:
    EAX=0x4047f0a4, EBX=0x404905a8, ECX=0x0807fed0, EDX=0x0807fed0
    ESP=0xbfff9f44, EBP=0xbfffa09c, ESI=0x00000000, EDI=0x0807fed0
    EIP=0x403afd0f, CR2=0x0000004c, EFLAGS=0x00010202
    Top of Stack: (sp=0xbfff9f44)
    0xbfff9f44: bfff9fac 47a6f6b8 00000000 00000000
    0xbfff9f54: 00000002 00000000 00000000 695f6d61
    0xbfff9f64: 0074696e bfff9f88 08080860 bfff9fac
    0xbfff9f74: 00000000 00000000 0807fed0 0807fed0
    0xbfff9f84: 08085c20 bfff9fa8 063afc44 bfffa01c
    0xbfff9f94: 47a6f568 47a6fbd8 0809cb08 bfff9fa8
    0xbfff9fa4: 40033ce0 bfff9fc8 47da1df4 47a6f568
    0xbfff9fb4: 40012f4c 47a6fbd8 40013ca6 40013ca6
    Instructions: (pc=0x403afd0f)
    0x403afcff: d2 0f 84 90 00 00 00 8b 75 10 8b 83 cc 09 00 00
    0x403afd0f: 8b 4e 4c 8b 38 89 8d d8 fe ff ff 85 ff 0f 85 4e
    Stack: [0xbfe00000,0xc0000000), sp=0xbfff9f44, free space=2023k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    V [libjvm.so+0x255d0f]
    V [libjvm.so+0x253654]
    C 0xffffe420
    C [libnet.so+0xdcbb] Java_java_net_SocketOutputStream_socketWrite0+0x1d1
    j java.net.SocketOutputStream.socketWrite0(Ljava/io/FileDescriptor;[BII)V+0
    j java.net.SocketOutputStream.socketWrite([BII)V+44
    j java.net.SocketOutputStream.write(I)V+15
    j java.io.DataOutputStream.writeInt(I)V+27
    j com.distrobot.common.util.WrappedOutputStream.write([BII)V+16
    j java.io.DataOutputStream.write([BII)V+7
    j java.io.DataOutputStream.writeUTF(Ljava/lang/String;Ljava/io/DataOutput;)I+426
    j java.io.DataOutputStream.writeUTF(Ljava/lang/String;)V+2
    j com.distrobot.common.ms.test.SimpleEnvMessage.encode(Lcom/distrobot/common/ms/IEnvMessage;Ljava/io/OutputStream;)V+26
    j com.distrobot.common.ms.TcpMessageProducer.sendOnce(Lcom/distrobot/common/ms/IEnvMessage;)Z+30
    j com.distrobot.common.ms.TcpMessageProducer.send(Lcom/distrobot/common/ms/IEnvMessage;)V+11
    j com.distrobot.common.ms.test.TcpMessageProducerTest.send(Lcom/distrobot/common/ms/ISession;Lcom/distrobot/common/ms/IDestination;
    Ljava/lang/String;)V+33
    j com.distrobot.common.ms.test.TcpMessageProducerTest.testSocketCache()V+232
    v ~StubRoutines::call_stub
    V [libjvm.so+0x168c1c]
    V [libjvm.so+0x254668]
    V [libjvm.so+0x168a4f]
    (etc)

  • WebLogic Server 6.1 SP 3 DocumentBuilder throws IOException: Stream closed

    Hi,
              I have a question about XML processing and error handling, and how the
              WebLogic container affects things.
              Here's what happens to us. We have a servlet parsing XML using DOM.
              The servlet has an InputStream with the content. It gets the default
              DocumentBuilderFactory
              (weblogic.xml.jaxp.RegistryDocumentBuilderFactory) and makes it
              validating. It asks for a DocumentBuilder. It gives the builder our
              own custom error handler to collect up all the SAX parse errors. It
              then tells the builder to parse the input stream. We would expect
              that any problems with the content would be reported as an error to
              our error handler, so that we can then report the errors to the user
              as part of the servlet response.
              However, certain malformed XML content causes the WebLogic parser to
              issue several error messages to System.out and throw an IOException
              with the message "Stream closed". No errors are recorded in our error
              handler. This happens on a variety of inputs, which all revolve
              around the root element start tag being malformed or entirely missing.
              We get this behavior with a totally empty stream, with a stream that
              has the <?xml> and <!DOCTYPE> headers but nothing else, with a stream
              that has the headers and then a malformed start tag like
              "<Submit_Contracts a="1"b="2"/>". I think the programmer would expect
              any of these inputs to cause the parser to simply report a fatal error
              and stop. Throwing an IOException makes it look like it's an error in
              the underlying stream, and clearly it's not. (Most of the test code I
              used actually pulled the XML from a ByteArrayInputStream.)
              Shouldn't WebLogic's parser handle these inputs differently? Throwing
              an IOException can't be correct, can it? Should the application
              instead be responsible for checking that the input has a well-formed
              start tag? In that case the application is doing the parsing that we
              want to rely on the parser to do! Should the application instead
              catch IOExceptions from the parser and report them to the user as
              input errors? In that case the application can potentially swallow
              and ignore harmful system errors.
              The messages on System.out are all along the lines of:
              "<Oct 17, 2002 5:38:03 PM EDT> <Error> <XML> <Failed to open XML
              document. Failed to retrieve PUBLIC id or SYSTEM id from the document.
              Decrease the number of char between the beginning of the document and
              its root element.>
              <Oct 17, 2002 5:38:03 PM EDT> <Error> <XML> <Failed to open XML
              document. Failed to retrieve PUBLIC id. Stream closed>
              <Oct 17, 2002 5:38:03 PM EDT> <Error> <XML> <Failed to parse given XML
              document. Failed to retrieve PUBLIC id. The root element is required
              in a well-formed document.>
              <Oct 17, 2002 5:38:03 PM EDT> <Error> <XML> <Failed to parse given XML
              document. Failed to retrieve SYSTEM id. The root element is required
              in a well-formed document.>
              <Oct 17, 2002 5:38:03 PM EDT> <Error> <XML> <Failed to open XML
              document. Failed to retrieve root tag. Stream closed>
              <Oct 17, 2002 5:38:03 PM EDT> <Error> <XML> <Could not instantiate
              factory class specified in the Server console. Invalid parameters: at
              least one of publicId,systemId, rootTag must be non-null>
              The IOException looks like:
              "java.io.IOException: Stream closed
              at java.io.BufferedInputStream.ensureOpen(BufferedInputStream.java:118)
              at java.io.BufferedInputStream.read(BufferedInputStream.java:268)
              at weblogic.apache.xerces.utils.ChunkyByteArray.fill(ChunkyByteArray.java:230)
              at weblogic.apache.xerces.utils.ChunkyByteArray.<init>(ChunkyByteArray.java:106)
              at weblogic.apache.xerces.readers.DefaultReaderFactory.createReader(DefaultReaderFactory.java:153)
              at weblogic.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:499)
              at weblogic.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:318)
              at weblogic.apache.xerces.framework.XMLParser.parse(XMLParser.java:974)
              at weblogic.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:183)
              at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:140)
              at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:86)
              at com.isone.sms.participant.contracts.web.WebLogicParserContainerTest.testWebLogicParserTanksOnEmptyStream(WebLogicParserContainerTest.java:448)
              at java.lang.reflect.Method.invoke(Native Method)
              at junit.framework.TestCase.runTest(TestCase.java:166)
              at junit.framework.TestCase.runBare(TestCase.java:140)
              at junit.framework.TestResult$1.protect(TestResult.java:106)
              at junit.framework.TestResult.runProtected(TestResult.java:124)
              at junit.framework.TestResult.run(TestResult.java:109)
              at junit.framework.TestCase.run(TestCase.java:131)
              at junit.framework.TestSuite.runTest(TestSuite.java:173)
              at junit.framework.TestSuite.run(TestSuite.java:168)
              at com.isone.sms.participant.contracts.web.ContractTestServlet.doPost(ContractTestServlet.java:23)
              at com.isone.sms.participant.contracts.web.ContractTestServlet.doGet(ContractTestServlet.java:16)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
              at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2546)
              at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2260)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)"
              Judging from the IOException, it looks as though WebLogic's wrapper
              parser, RegistryDocumentBuilder, successfully picked a real parser to
              do its work and is passing off the input to be parsed there, even
              though the input's already closed. Perhaps the
              RegistryDocumentBuilder silently screwed up the stream while trying to
              figure out what parser to use, but didn't take that into account
              before attempting to pass it off for parsing. Perhaps the error
              messages on System.out account for when RegistryDocumentBuilder is
              screwing up the stream.
              But if RegistryDocumentBuilder discovers that the stream can't be
              parsed, why can't it simply report a fatal error and stop before
              starting the real parser?
              Mainly I wanted to put this experience up here on a newsgroup because
              I was so surprised that nobody else had reported similar problems. It
              makes me doubt whether our applications are handling the XML parsing
              correctly. But I can't see any other way that makes sense. Please
              let me know what you think!
              Thanks,
              Jim
              

    Hi,
    I got this error when i used JRUN as plugin server through
    Ineternet Information Server. but it was working fine when used it
    as standalone server.
    The reason was beacuase, the inputstream was getting closed . when i removed it, it started working.
    (To be frank , the Inputstream was closed by XML DOM PARSER , which is third party component.)
    and believe that your case is also the same ....
    If you have doubt on that then see that configuration for proxies under your webservers config files
    best of luck
    LOkesh T.C

  • Servlet throws IOException when browser is "stopped"

    Hello,
    I have a servlet running on the Sun ONE Web server 6.1 that throws this error message: "java.io.IOException: WEB8004: Error flushing the output stream".
    Through my testing, it seems as if this is caused by the user pressing the stop button before the output can be completely commited to the client. Strangely enough the error seems to thrown when IE is the browser but not when Firefox is. My guess is that what is happening is the client connection is closed when stop is pressed in IE and the server cannot write to the client anymore so the error is thrown.
    I was wondering if anyone has any insight into how to prevent this from getting thrown. I realize that this error is not a major thing and probably doesn't need to be worried about, but it is quite annoying because webmaster gets emailed anytime an exception is thrown so cutting down on pointless exceptions is something we like to do :)
    Thanks in advance.

    You could also try hitting the browser's refresh button many times as quickly as possible; it should also give similar errors. Or keep Control-R (reload) pressed down and let the keyboard's auto-repeat do its work.
    When the browser is in the process of fetching a page and decides it isn't interested in the page after all, it closes the TCP/IP connection to the server. The server will get an IOException. Nothing you can do about that. Write a catch block that ignores IOException when flushing a web page. Or maybe log "error sending page, the user probably hit the reload button", without the stack trace, into an audit log.

  • Stream connection throws IOException

    i am using a stream connection for the midp 1.0. The client logs into a server using a StreamConnection and all this is cool.
    But the application waits at the DataInputStream.read and then thows the IOException.
    my code is something like this,,
    while(true)
    if ((i = dataInputStream.read()) == -1)
    // some logic here
    the dataInputStream.read() throws the exception after approximately 7 to 8 seconds.
    anyone has an idea as to whats going wrong? why is the connection not being maintained.
    Thankyou,
    Balaji.

    Thankyou shmoove. The code is here.
    The server is setup to send information every 3 seconds to the client (upon client request,, which is working fine). For your reference,, the same code works perfectly fine with a Series 60 (midp2.0) phone, and so does the server. except that i use a SocketConnection for the midp 2.0 phone. For the very reason that midp 1.0 does not support the SocketConnection, i have to use a StreamConnection instead. the dataInputSream is bound with the StreamConnection object.
    I think the StreamConnection is somehow not persistant ,, in the sense the connection is not maintained.
    Please tell me whats wrong,
    Thankyou,
    Balaji.
    public Alert alertConnBroken = new Alert("", "Due to weak wireless link, Connection to server lost. Please reconnect!!", null, AlertType.WARNING);
    public String readString()
         String str = new String();
         while(true)
              try
                   if((ch = (char) dataInputStream.read()) == -1)                   
                        display.setCurrent(alertConnBroken);
                        break;
                   else
                      str = str + ch;
              catch(InterruptedIOException iioe)
                   iioe.printStackTrace();
                   break;
              catch (IOException ioe)
                   ioe.printStackTrace();
                   break;
                catch(EOFException eofe)                     
                    eofe.printStackTrace();                                        
                 break;
             catch (Exception e)
                e.printStackTrace();
                 break;
         return str;     
         

  • VirtualMachine.loadAgent() throws IOException

    Hi, everybody
    I wrote a tiny program to dynamically load an agent to the target VirturalMachine using JDK 6. The code is listed below.
    import java.util.List;
    import com.sun.tools.attach.VirtualMachine;
    import com.sun.tools.attach.VirtualMachineDescriptor;
    public class AttachThread extends Thread {
         private final List<VirtualMachineDescriptor> listBefore;
         private final String jar;
         AttachThread(String attachJar, List<VirtualMachineDescriptor> vms) {
              listBefore = vms;
              jar = attachJar;
         public void run() {
              VirtualMachine vm = null;
              List<VirtualMachineDescriptor> listAfter = null;
              try {
                   int count = 0;
                   while (true) {
                        listAfter = VirtualMachine.list();
                        for (VirtualMachineDescriptor vmd : listAfter) {
                             if (!listBefore.contains(vmd)) {
                                  vm = VirtualMachine.attach(vmd);
                                  break;
                        Thread.sleep(500);
                        count++;
                        if (null != vm) {
                             break;
                   vm.loadAgent(jar);               
                   vm.detach();
              } catch (Exception e) {
                   e.printStackTrace();
         public static void main(String[] args) throws InterruptedException {
              new AttachThread("agent.jar", VirtualMachine.list()).start();
    }The above code works fine with my first testcase. But when I tested it with a bigger testcase, it throws java.io.IOException at vm.loadAgent(jar)
    The details are listed below:
    java.io.IOException: Access is denied.
         at sun.tools.attach.WindowsVirtualMachine.enqueue(Native Method)
         at sun.tools.attach.WindowsVirtualMachine.execute(WindowsVirtualMachine.java:78)
         at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:40)
         at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:61)
         at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:85)
         at com.sun.tools.attach.VirtualMachine.loadAgent(VirtualMachine.java:508)
         at AttachThread.run(AttachThread.java:37)Dose anybody know what is the cause of this exception? The document just said that it is thrown "If an I/O error occurs ".
    Thanks in advance!
    Regards,
    Vivian

    Why have u introduced a timeout in your thread? What happens when u increase the time of waiting (thinking of your second example)?

  • Response.sendRedirect throws IOException

    I am using jsdk2.0 and I am using servlet runner to test this servlet.
    In my servlet if a person is authorized I am sending the person to a particular URL.
    if(rs.next())
    response.sendRedirect(response.encodeRedirectUrl("https://xyz.com"));
    It does go to the URL but It throws a exception which I can see in the servlet runner... IT Says java.io.IOException: Tried to write more than the content length..
    sun.servlet.HttpOutputStream.check(HttpOutputStream:java:282)..Dont have a 282 line...
    Can someone tell me...I know I am using deprecated method but why is it giving an exception?

    your using https which is not supported by sendRedirect as far a i know. There is a special package for ssl afaik.

  • ObjectInputStream throws IOException

    AA,
    Dear All,
    when I compile the below command everything is fine, but it throws an IOException while running the program.
    The problem is not in catching the exception. The problem is that so I'll not be able create an instance of ObjectInputStream.
    By the way the incoming is Socket and it's not null (I've checked that).
    ObjectInputStream inputData = new ObjectInputStream(incoming.getInputStream());
    Why is the IOException thrown? This is the actual question.
    I hope I was clear
    Waiting for replies...

    Post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and http://www.yoda.arachsys.com/java/newsgroups.html

Maybe you are looking for

  • Service desk message not seen in SOLMAN

    Hi Gurus! We are creating a service desk message in R\3 system that should be displayed in SOLMAN. But it is not displayed in solution manager. Could you please specify what steps shouls i have to do inorder to get that message displayed. Thanks in A

  • Differences between adobe premiere elements 8 and adobe premiere pro cs4

    I'm planning to download either adobe premiere elements 8 or adobe premiere pro cs4, but first would like to know their differences in regards to features that best suits me.

  • CUA Stats

    Hello; I am looking for a document where CUA survey has been done by some company or by SAP showing the %'s it reduces amount of user admin time Please advice Ayaz

  • I installed Snow Leopard and now I can't import pictures from iphone or memory chip.

    I installed Snow Leopard to my Mac Book Pro and when I went to import pictures from my Iphone 4 to the Mac I received a message that it could not read the files.  I also tried importing pictures from my camera's memory card and got the same error.  T

  • Redeploying with 7.0.4 in redhat 7.3

    I'm having some trouble with redeployment of ear files. I'll describe what is happening: 1 - I deploy my appl, all works OK 2 - I make a few changes in the body of an auxiliary class (not part of an Entity nor a Session) 3 - I make my ear from scratc