> How are you getting the InputStream for the Jar file? URL fileUrl = this.getClass().getClassLoader().getResource(file); InputStream is = fileUrl.openConnection().getInputStream(); DataInputStream dis = new DataInputStream( is ); InputStreamReader isr = new InputStreamReader( dis ); BufferedReader br = new BufferedReader( isr );
I already fixed the problem but not completely, I realized that when the jar file is compressed, the java.util.zip.InflaterInputStream can't read the content-length (always get -1) so that's why it cannot read the file properly. But this doesn't happen when the jar file is compressed and outside the war file. The solution was to pack the jar file but uncompressed and then put it inside the war (the war can be compressed). Thanks for your help and attention ----- Original Message ----- From: "Gokul Singh" <[EMAIL PROTECTED]> To: "'James Smith'" <[EMAIL PROTECTED]> Sent: Thursday, April 03, 2003 10:09 PM Subject: RE: ZipException from a jar within a war file > > > -----Original Message----- > > From: A mailing list for discussion about Sun Microsystem's > > Java Servlet API Technology. > > [mailto:[EMAIL PROTECTED] On Behalf Of James Smith > > > Hi > > > > I'm deloying a web application packed in a war file. I'm > > using a jar file within the war file as a library > > > > This library reads a text file that is in the jar and it > > works properly running the test application of that jar file > > using (java -jar library.jar), but when I use the library, > > packaged within the war file it throws a ZipException when > > try to read from the file. I don't want to extract all the > > files in the jar to add them to the war but use the library > > as the jar > > How are you getting the InputStream for the Jar file? > > > > > > I'm using JBOSS jboss 3.0.0 with bundeled tomcat 4.0.3 > > > > I really don't know what happen 'cause I tested the jar file > > independent and worked fine reading the text file but when > > packaged in the war doesn't works > > > > Thanks for your help > > > > bye > > > > James > > > > > > This is the exception and part of the stack trace > > ---------------------------------------- > > invalid stored block lengths > > java.util.zip.ZipException: invalid stored block lengths > > at > > java.util.zip.InflaterInputStream.read(InflaterInputStream.java:139) > > at java.io.DataInputStream.read(DataInputStream.java:167) > > at > > sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:404) > > at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:442) > > at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:179) > > at java.io.InputStreamReader.read(InputStreamReader.java:167) > > at java.io.BufferedReader.fill(BufferedReader.java:136) > > at java.io.BufferedReader.readLine(BufferedReader.java:299) > > at java.io.BufferedReader.readLine(BufferedReader.java:362) > > > > ______________________________________________________________ > > _____________ > > To unsubscribe, send email to [EMAIL PROTECTED] and > > include in the body of the message "signoff SERVLET-INTEREST" > > > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > > Resources: > > http://java.sun.com/products/servlet/external-> resources.html > > > > LISTSERV Help: > > http://www.lsoft.com/manuals/user/user.html > > > > > > > > > > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html