10 Replies Latest reply: Feb 11, 2008 5:47 AM by 807603 RSS

    IOException - Stream closed

    807603
      My code runs well when I am using eclipse but when i create a jar and run, it shows the error as below. Have tried lot of searching but couldn't arrive at the possible solution; chiefly coz things work perfect when main class is run using eclipse. (code also attached below the logs)
      ----------------------------------------------------------------------

      6:31:52 PM [error] ModeProvider: java.io.IOException: Stream closed
      6:31:52 PM [error] ModeProvider: at java.io.BufferedInputStream.getInIfOpen(Unk
      nown Source)
      6:31:52 PM [error] ModeProvider: at java.io.BufferedInputStream.fill(Unknown So
      urce)
      6:31:52 PM [error] ModeProvider: at java.io.BufferedInputStream.read(Unknown So
      urce)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      EntityManager$RewindableInputStream.read(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      EntityManager.setupCurrentEntity(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      EntityManager.startEntity(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      EntityManager.startDTDEntity(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      DTDScannerImpl.setInputSource(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      DocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      DocumentScannerImpl$DTDDriver.next(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      DocumentScannerImpl$PrologDriver.next(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      DocumentScannerImpl.next(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      NSDocumentScannerImpl.next(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.impl.XML
      DocumentFragmentScannerImpl.scanDocument(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.parsers.
      XML11Configuration.parse(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.parsers.
      XML11Configuration.parse(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.parsers.
      XMLParser.parse(Unknown Source)
      6:31:52 PM [error] ModeProvider: at com.sun.org.apache.xerces.internal.parsers.
      AbstractSAXParser.parse(Unknown Source)
      6:31:52 PM [error] ModeProvider: at org.gjt.sp.jedit.syntax.ModeProvider.loadMo
      de(ModeProvider.java:163)
      6:31:52 PM [error] ModeProvider: at org.gjt.sp.jedit.syntax.ModeProvider.loadMo
      de(ModeProvider.java:206)
      6:31:52 PM [error] ModeProvider: at org.gjt.sp.jedit.textarea.TextArea.<init>(T
      extArea.java:164)
      6:31:52 PM [error] ModeProvider: at org.gjt.sp.jedit.textarea.TextArea.<init>(T
      extArea.java:71)
      6:31:52 PM [error] ModeProvider: at org.gjt.sp.jedit.textarea.TextArea.main(Tex
      tArea.java:6189)
      6:31:52 PM [warning] JEditBuffer: invalid 'folding' property: none
                
                              XMLReader parser = null;
                try {
                     parser = XMLReaderFactory.createXMLReader();
                } catch (SAXException saxe) {
                     Log.log(Log.ERROR, jEdit.class, saxe);
                     return;
                }
                mode.setTokenMarker(xmh.getTokenMarker());
      
                InputStream grammar = null;
      
                try
                {
                     grammar = new BufferedInputStream(
                          new FileInputStream(fileName));
      
                     InputSource isrc = new InputSource(grammar);
                     isrc.setSystemId("jedit.jar");
                     parser.setContentHandler(xmh);
                     parser.setDTDHandler(xmh);
                     parser.setEntityResolver(xmh);
                     parser.setErrorHandler(xmh);
      (line no 163)          parser.parse(isrc);
      
                     mode.setProperties(xmh.getModeProperties());
                }
        • 1. Re: IOException - Stream closed
          800456
          Print out your classpath at te beginning of main - I bet its differentin each case
          • 2. Re: IOException - Stream closed
            807603
            Do you mean my classpath is not correct for the created jar...
            ( i believe i am not properly including the external jars but then it shouldn't have built in the first place)
            • 3. Re: IOException - Stream closed
              800456
              Try it and see
              • 4. Re: IOException - Stream closed
                807603
                thanks
                they are indeed different
                /C:/Documents%20and%20Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/build/
                jedit-textArea.jar


                /C:/Documents%20and%20Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/bin/
                /C:/Documents%20and%20Settings/shlahoti/Desktop/apache-ant-1.7.0-bin/apache-ant-1.7.0/lib/ant.jar;
                /C:/Documents%20and%20Settings/shlahoti/Desktop/apache-ant-1.7.0-bin/apache-ant-1.7.0/lib/xml-apis.jar;
                /C:/Program%20Files/Java/jdk1.6.0_04/lib/tools.jar;
                /C:/Documents%20and%20Settings/shlahoti/Desktop/Xerces-J-bin.2.9.1/xerces-2_9_1/serializer.jar
                /C:/Documents%20and%20Settings/shlahoti/Desktop/Xerces-J-bin.2.9.1/xerces-2_9_1/xercesImpl.jar

                but I earlier have tried packing my external jars with the new jar but it is not working and it seems to me i am just going by the book.. can you (anyone) just have a look - i have tried several different ways - one being...

                <manifest>
                                    <attribute name="Main-Class" value="org.gjt.sp.jedit.textarea.TextArea"/>
                                    <attribute name="Class-Path" value="C:/Documents and Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/jars/serializer.jar C:/Documents and Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/jars/tools.jar C:/Documents and Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/jars/xercesImpl.jar C:/Documents and Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/jars/xml-apis.jar C:/Documents and Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/jars/ant.jar"/>
                               </manifest>
                • 5. Re: IOException - Stream closed
                  800456
                  Check carefully for case match .. and do those spaces need quotes or escapes?
                  • 6. Re: IOException - Stream closed
                    807603
                    1st - my app jar and all other external jars are placed in same folder - in that case i believe it isnt required to mention those ext jars in classpath ( so in that case it should work fine)

                    2nd - have tried different combination as well solution given in http://forum.java.sun.com/thread.jspa?threadID=785899
                    using leading slashes; providing absolute path still classpath is only /C:/Documents%20and%20Settings/shlahoti/Desktop/jedit4.3pre12source/jEdit/build/jedit-textArea.jar and not shows external dependencies
                    • 7. Re: IOException - Stream closed
                      807603
                      to be more clear this is what i have done
                      <target name="copy-depend-jars"
                                     description="copy dependent jars to dist dir">
                              <copy todir="${jar.location}" file="jars/serializer.jar" />
                              <copy todir="${jar.location}" file="jars/tools.jar" />
                              <copy todir="${jar.location}" file="jars/xercesImpl.jar" />
                              <copy todir="${jar.location}" file="jars/xml-apis.jar" />
                              <copy todir="${jar.location}" file="jars/ant.jar" />
                           </target>
                      
                           <target name="build-textArea"
                                     depends="init,compile,copy-depend-jars"
                                <mkdir dir="${jar.location}" />
                                <jar destfile="${jar.location}/${ant.project.name}-textArea.jar"
                                description="build the textArea JAR-file with full debug-information">
                      .................................................
                      .................................................
                                     <manifest>
                                          <attribute name="Main-Class" value="org.gjt.sp.jedit.textarea.TextArea"/>
                                     </manifest>
                      </jar>
                      </target>
                      I have tried also with
                      <attribute name="Class-Path" value = .... />
                      can any one give the syntax of how to give this value for multiple external jars (absoulte path) and also when they are in same folder as application jar

                      Nothing seems to wrok.. as of now!!!
                      • 8. Re: IOException - Stream closed
                        807603
                        any one....!!! ???
                        • 9. Re: IOException - Stream closed
                          EJP
                          IOException - Stream closed
                          To start back at the beginning, this exception means that you are trying to read from a stream which you have already closed yourself.
                          • 10. Re: IOException - Stream closed
                            807603
                            dats true.. but the point which i am trying to make here is tha in eclipse things work fine but not when I create a jar independently and run. Therefore the reason told earlier seems to be correct - i.e classpath problem but then I am not able to figure out why the ext jars not being detected