participate


Java Plug-In - with java 1.6 an applet cannot read a jar file if the file is cached
This question is not answered.

<<   Back to Forum  |   Give us Feedback Topics: « Previous | Next
This topic has no replies.
FrancoisR
Posts:3
Registered: 10/4/06
with java 1.6 an applet cannot read a jar file if the file is cached   
Nov 19, 2007 11:40 PM
 
 
I use the javaHelp framework in an applet to display html pages. Until java 1.6 the full text search worked great, but it fails since java 1.6. Apparently the problem comes from a jar file (with the html data) being not load. I post the following bug in the database but since I hade no information back, I would be glad is someone could test my code below.
Thanks
Francois

java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested with Firefox Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9

A DESCRIPTION OF THE PROBLEM :
With java 1.6 an applet cannot read a jar file in the same directory if "Keep the temporary files on my computer" is checked in the java console (in XP control Panel)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a jar file named test.jar with a file named msg2.txt in it. Placed in a server in the same directory then the applet class file.

2) Create a html file with the code

<APPLET CODE = "ApJarUrls" ARCHIVE = "test.jar"
WIDTH = 900 HEIGHT = 500>


3) Compile the java file geven below (adapted from bug 6456667) and placed the class file in the same directory then the jar file on the server. Here the directory is dokpe/procedures


the java console gives the following output

Good: test2.txt doesn't exist.
msg2 available: 2686
java.util.zip.ZipException: ZipFile closed
at java.util.zip.ZipFile.ensureOpenOrZipException(Unknown Source)
at java.util.zip.ZipFile.access$1100(Unknown Source)
at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source)
at java.util.zip.ZipFile$1.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at ApJarUrls.init(ApJarUrls.java:31)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The java console gives

Good: test2.txt doesn't exist.
msg2 available: 2686
msg2 read: 69

ACTUAL -
the line test1Stream.read() throws a ZipFile closed exception

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.zip.ZipException: ZipFile closed
at java.util.zip.ZipFile.ensureOpenOrZipException(Unknown Source)
at java.util.zip.ZipFile.access$1100(Unknown Source)
at java.util.zip.ZipFile$ZipFileInputStream.read(Unknown Source)
at java.util.zip.ZipFile$1.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at ApJarUrls.init(ApJarUrls.java:31)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


REPRODUCIBILITY :
This bug can be reproduced always.


BEGIN SOURCE

//Change the path to the directory in the server and compile:

//ApJarUrls.java
//code from from 6456667
import java.io.;
import java.net.
;
import javax.swing.JApplet;

public class ApJarUrls extends JApplet {
public ApJarUrls(){super();}
public void init() {
InputStream test1Stream=null;
URL test2 = null;
try {

// public static void main(String[] args) throws Exception {
File jarFile = new File("test.jar");

String jarUrl = "jar:http://localhost/dokpe/procedures/test.jar!/";
URL test1 = new URL(jarUrl "msg2.txt");
test1Stream = new BufferedInputStream(test1.openStream());
test2 = new URL(jarUrl
"test2.txt");

try {
InputStream test2Stream = new BufferedInputStream(test2.openStream());
throw new RuntimeException("Test 2 somehow existed.");
} catch(FileNotFoundException e) {
System.err.println("Good: test2.txt doesn't exist.");
}

System.err.println("msg2 available: " test1Stream.available());
System.err.println("msg2 read: "
test1Stream.read());
} catch (IOException e){e.printStackTrace();}
}//init
}

END SOURCE

CUSTOMER SUBMITTED WORKAROUND :
In the Control Panel open Java, turn off "Keep temporary files on my computer" and the applet works as expected.
 
This topic has no replies.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 133

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums