ClassNotFoundException 仅当 JAR 已签名时 [英] ClassNotFoundException only if JAR is signed

查看:22
本文介绍了ClassNotFoundException 仅当 JAR 已签名时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个难题!

我在 JAR 中有一个小程序.当 JAR 被签名时——无论是自签名还是带有 DigiCert 证书——我在主小程序类上得到一个 ClassNotFoundException.当我签署小程序时,它加载得很好 - (由于代码未签名,不计算预期的SecurityException).

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

但我可以打开已签名的 JAR 文件并找到所有内容.

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

最奇怪的是,直到上周为止,设置都运行良好.相同的主类,自签名,相同的 JS/HTML 部署组合等

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.

有什么想法吗?

错误信息如下:

java.lang.ClassNotFoundException: com.spraklab.ilos.applet.Applet
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:195)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)

推荐答案

简短版本:JAR 名称中没有连字符!

Short version: No hyphens in JAR-names!

戏剧性的故事:最后!发现问题后许多个工作日.未签名时小程序加载良好,签名时出现 ClassNotFoundException.关于类加载器切换的答案让我相信我的代码中发生了一些变化.所以我把我的代码精简到最低限度.但是为了避免一直重新启动浏览器并清空缓存等,我只是使用了 Chrome 的隐身模式.我重建了代码.最后一切都很好.不是!然后,当我在隐身模式之外对其进行测试时,再次出现错误.

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.

那么有什么不同呢?对服务器日志的检查表明,在常规模式下,根本没有从服务器请求 Jar!我再次将我的代码与具有类似嵌入代码的不同应用程序进行比较,只看到一个区别:我在 JAR 名称中使用了连字符而不是下划线 - 这应该是允许的,并且一直运行良好,直到大约 2 周前.但是大约 2 周前不是也有 Java 更新吗...?!?!

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 ...?!?!

这篇关于ClassNotFoundException 仅当 JAR 已签名时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆