Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Applet not caching

I'm having a problem with a Java applet I've deployed that is refusing to be cached in the jvm's "sticky" cache (or by the browser). For some reason every time a user loads the page this applet is on, the jvm re-downloads the jar file from the server which causes a long delay.

The webpage containing the applet is being accessed via the internet, so according to Sun's Java applet documentation I'm using an <applet> tag rather than an <object> or <embed> tag.

Any help debugging or identifying the problem would be much appreciated.

Below is the full applet tag I'm using:

<applet alt="Scanning Applet failed to load" archive="scanning.jar"
        code="scanning.scanlet.class" codebase="/java/" codetype="application/java"
        height="30" mayscript="True" name="scanlet" width="200">
    <param name="domain" value="192.168.12.23" />
    <param name="publishName" value="scan_attachment" />
    <param name="publishURL" value="http://192.168.12.23/draft/update/52" />
    <param name="curURL" value="http://192.168.12.23/draft/edit/52" />

Your browser is unable to process the Java &lt;APPLET&gt; tag needed to display this applet
<br />
One solution would be to download a better web browser like
<a href="http://www.mozilla.com/firefox">Mozilla's Firefox</a>

</applet>
like image 581
John Fogerty Avatar asked Apr 22 '10 20:04

John Fogerty


People also ask

Why is applet not working?

The Java bit version must match your browser's bit version. If your browser is 32-bit, your Java must be 32-bit. If your browser is 64-bit, your Java must be 64-bit. If you have a 32-bit browser and 64-bit Java, or a 64-bit browser and 32-bit Java, applets will not load.

Is Java applet still in use?

The applet element was deprecated in HTML 4.01 and rendered entirely obsolete by HTML5. Support for the Java browser plugin has been dropped by virtually all leading web browsers.

What does clearing Java cache do?

Clearing the Java Plug-in cache forces the browser to load the latest versions of web pages and programs. Clear Java cache by deleting Temporary Files through the Java Control Panel.

What is Java caching?

The Java Object Cache provides caching for expensive or frequently used Java objects when the application servers use a Java program to supply their content. Cached Java objects can contain generated pages or can provide support objects within the program to assist in creating new content.


2 Answers

I had the very same problem and found a trick that need to be applied server side. It seems that jars aren't cached if their mime type is incorrect. Please check your server reply using the application/java-archive mime type.

Another problem I found is related to a specific jar. My archive parameter was listing many jars, but only a few were cached. I found that all jars upto a specific one where cached, all remaining jars weren't cached at all. While loading applet, I pressed "5" in its java console and found this message just after the last cached jar: cache: signed entry missing from jar . I still don't know what is wrong with this file, but I moved that jar at the end of the archive parameter list. This "fixed" the problem.

like image 78
eppesuig Avatar answered Oct 15 '22 10:10

eppesuig


Personally I solved the caching issues by using cache_archive and cache_version parameters docummented at http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/applet_caching.html

My cache_version is based on the actual file modification date, e.g.

val archive = libs.map("/" + _.getPath).mkString (", ")
val version = libs.map(_.getUpdated / 1000 / 20 - 59281420).mkString (", ")

and to work with MSIE it looks as:

if (msie) {
  cms write <OBJECT
    classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
    codebase="http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab"
    width="100%" height="100%">
    ...
    <PARAM name="cache_archive" value={archive}/>
    <PARAM name="cache_version" value={version}/>
  </OBJECT>
} else {
  cms write <applet ...
    cache_archive={archive} cache_version={version}></applet>
}
like image 25
ArtemGr Avatar answered Oct 15 '22 10:10

ArtemGr