0

I have an applet based application that uses following classes:

  • javax.xml.parsers.DocumentBuilderFactory
  • javax.xml.parsers.DocumentBuilder
  • javax.imageio.ImageIO
  • javax.imageio.ImageWriteParam
  • javax.imageio.ImageWriter
  • javax.imageio.stream.FileImageOutputStream . . etc

This is how I am initializing the applet:

 var attributes = {
   codebase : "http://example.com/urlto/jars",
   code     : "AppletLauncher.class",
   archive  : "MyApp.jar?v=" + Math.random()
};

var parameters = {"java_arguments": "-Xmx512m"};

deployJava.runApplet(attributes, parameters, "1.6");

The applet makes several GET request. Here are some of the example requests:

[GET]  /urlto/jars/META-INF/services/javax.imageio.spi.ImageInputStreamSpi
[HEAD] /urlto/jars/META-INF/services/javax.imageio.spi.ImageInputStreamSpi
[GET]  /urlto/jars/META-INF/services/javax.imageio.spi.ImageTranscoderSpi
[HEAD] /urlto/jars/META-INF/services/javax.imageio.spi.ImageTranscoderSpi
[GET]  /urlto/jars/META-INF/services/javax.imageio.spi.ImageReaderSpi
[GET]  /urlto/jars/META-INF/services/javax.imageio.spi.ImageOutputStreamSpi
[GET]  /urlto/jars/META-INF/services/javax.imageio.spi.ImageWriterSpi
[GET]  /urlto/jars/META-INF/services/javax.xml.parsers.DocumentBuilderFactory

I read this post, and it mentions about disabling codebase_lookup, that didn't work for me either.

I understand the classloader will first look up the classes in JVM and the applet jar file. If it doesn't find it, it will lookup in codebase and make those request. If it is true, I am using all core classes, why should it make any requests? How can I enforce it to not make these requests?

The applet finally gets initialized when all the requests fail but it takes too long for the applet to startup.

In the application, I am just reading JPEGs in BufferedMemory and writing JPEGs from BufferedMemory.

Community
  • 1
  • 1
Mo3z
  • 2,138
  • 7
  • 21
  • 29
  • 1) `archive : "MyApp.jar?v=" + Math.random()` Change that nonsense to `archive : "MyApp.jar"` 2) *"I read this post, and it mentions about disabling codebase_lookup. When I do that, it doesn't even load MyApp.jar and hence won't initialize the application."* That is *not* how it is ***intended*** to work.. [i.e.](http://docs.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/special_attributes.html#specialattributes) – Andrew Thompson Jul 19 '13 at 18:17
  • 1) The reason I had that is because I needed to reload the jar every time I test something. I respect your concern, but that is not really the question. 2) I updated my question. I was making some silly comma mistake so it wasn't initializing but even after fixing that, it didn't work for me. Thanks! – Mo3z Jul 21 '13 at 05:02
  • *"that is not really the question."* Since they might be causing the problems, I'll concentrate on 'the question' as soon as all these 'questionable things' are attended to. – Andrew Thompson Jul 21 '13 at 06:31
  • @Andrew, I removed that and it still make those requests. Thanks! – Mo3z Jul 21 '13 at 19:27

1 Answers1

0

I was using eclipse inbuilt export Runnable Jar functionality to create the jar file. It was creating its own MANIFEST file and adding the following parameter

Class-Path: .

So, I used that ant script but removed this parameter to create the jar file and it stopped making those request. I am not sure what was the problem. I am guessing, it was looking for those SPI files in "." path which it didn't find so it made those remote requests. If anyone have ideas, please comment. Thanks!

Mo3z
  • 2,138
  • 7
  • 21
  • 29