ClassNotFoundException solo si JAR está firmado

It is a conundrum!

I have an applet in a JAR. When JAR is signed - be it autofirmado or with a DigiCert sertificate - I get a ClassNotFoundException on the main applet class. When I no sign the applet, it loads just fine - (not counting the expected SecurityException due to the code not being signed).

But I can unpack the signed JAR and find everything to be where it is supposed to be.

The strangest part is that up until last week the set-up worked just fine. Same main class, self-signed, same deployment mix of JS/HTML etc.

¿Alguna idea?

Aquí está el mensaje de error:

java.lang.ClassNotFoundException: com.spraklab.ilos.applet.Applet
at sun.plugin2.applet.Applet2ClassLoader.findClass(
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(
at sun.plugin2.applet.Plugin2Manager.createApplet(
at sun.plugin2.applet.Plugin2Manager$

preguntado el 28 de agosto de 12 a las 13:08

It sounds like, for some reason, the signature is checking out bad. Has your certificate expired? -

No. This is a new certificate. And the same signing-code is used on another applet, and that one works just fine ... -

One workday later - and I haven't solved it yet. BUT: I have discovered that the exact same URL/HTML/JAR/applet works fine when loaded in a Chrome "incognito-window" or in Safari's "Private" mode - but fails when in regular window. Interesting! -

Something odd about your clock, perhaps? Or (more likely) maybe your system's certificate chain is mucked up. -

2 Respuestas

In the code above you are trying to switch secure applet classloader. That is not allowed since Java 1.2.

Respondido 28 ago 12, 13:08

What might be causing that? I don't know that I am doing anything special to try to make that happen ... - Terje Dahl

Short version: No hyphens in JAR-names!

The dramatic story: Finally! Many work-days after the problem was discovered. The applet loaded fine when not signed, bud ClassNotFoundException when signed. The answer about the switching of classloaders led me to believe that there was something I had changed in my code. So I stripped my code down to a minumum. But to avoid having to restart my browser all the time and empty the cache etc, I simply used the incognito-mode of Chrome. I rebuilt the code. And everything was fine in the end. Not! When I then tested it outside of incognito, I got the error again.

So what was the difference? An examination of the server logs showed that the Jar simply wasn't being requested from the server when in regular mode! I compared my code once again against an different app with similar embed-code, and saw only one difference: I was using a hyphen in stead of an underscore in the JAR-name - which should be allowed, and which had worked fine up until about 2 weeks ago. But wasn't there also a Java update about 2 weeks ago ...?!?!

Respondido 30 ago 12, 23:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.