Java Applet 部署,ClassNotFoundException(主类) [英] Java Applet Deployment, ClassNotFoundException (primary class)

查看:24
本文介绍了Java Applet 部署,ClassNotFoundException(主类)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这把我逼上了绝路.我已经检查并重新检查了拼写和路径.我尝试了几乎所有路径组合,包括相对、绝对和完整的 http 路径.尝试加载 Java 小程序时,我继续收到以下错误:

This is driving me up the wall. I have checked and rechecked spelling and paths. I have tried just about every combination of paths, including relative, absolute, and full http paths. I continue to get the following error when trying to load a Java applet:

java.lang.ClassNotFoundException: AppletClient.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassNotFoundException: AppletClient.class

用于加载小程序的 HTML:

The HTML used to load the applet:

<applet width="100" height="100" archive="applet/myapplet.jar, applet/applet_dependency.jar" code="AppletClient.class">
    <param value="blahblah" name="username">
    <param value="false" name="codebase_lookup">
</applet>

小程序位于当前页面路径的相对目录小程序"中.我已经解压了 jar 文件,可以看到 AppletClient.class.此外,在项目的源代码中,它是这样拼写的(外壳和所有).我试过带/不带参数.我已经更改了小程序包含标记中存档 jar 的名称,只是为了查看我是否因错误的文件名而收到不同的错误(相同的错误).

The applet is in a relative directory, "applet", from the path of the current page. I have unzipped the jar file and can see AppletClient.class. Also, in the source of the project, it is spelled that way (casing and all). I have tried with/without the parameters. I have changed the names of the archive jars in the applet include tag just to see if I get a different error for bad file names (same error).

我已经在 jars 上手动完成了 GET,以确保服务器响应请求(确实如此).

I have manually done GETs on the jars to make sure the server is responding to the requests (it is).

我尝试过使用和不使用代码库标签,以及各种不同的路径(开始在这些路径上出现错误的幻数"错误).

I have tried with and without the codebase tag, with all different varieties of paths (start getting bad "magic number" errors on those).

我知道有时会在依赖项加载失败时弹出此错误,因此它可能会产生误导,但所有依赖项都存在、已考虑并且可通过手动 GET 获取.

I know that this error sometimes pops up when a dependency fails to load, so it can be misleading, but all dependencies are present, accounted for, and are fetchable via manual GETs.

在每次尝试之间,我总是清除 FireFox 中的缓存.这些问题在 IE8 和 Chrome 中也重现.

Between each and every attempt I always clear my cache in FireFox. These problems are reproduced in IE8 and Chrome as well.

根据浏览器中的 Java 控制台,我正在运行 Java 插件 1.6.0_20.这是来自我开发小程序的同一台机器,它通过 Eclipse 运行良好.

Per my Java Console from the browser, I am running Java Plug-in 1.6.0_20. This is from the same machine that I develop the applet on, which runs fine via Eclipse.

最后,我开始使用 Fiddler2,我在任何地方都没有看到对 jar 文件的单个请求 主机站点从我的 Visual Studio 调试器运行,因此它在本地主机上运行.但是我在 Fiddler 上看到了对所有其他资源的请求.只是……没有罐子.任何地方.我清除日志,清除浏览器缓存,并按 ctrl-R 刷新.而且,Fiddler 日志中没有一个 Jar 请求.

Finally, I kicked on Fiddler2, and I don't see a single request for the jar files anywhere The host site is running from my Visual Studio debugger, so it's running on localhost. But I see the requests for all the other resources on Fiddler. Just... no Jars. ANYWHERE. I clear the log, cleared my browser cache, and did a ctrl-R refresh. And still, not a single Jar request on the Fiddler log.

我什至在页面加载后延迟写入(使用 JS)小程序标记,一旦所有 Fiddler 活动都变慢了.元素被写入文档(我可以看到 100x100 Java 错误窗口),但 Fiddler 上没有显示单个请求.

I even did a delayed write (with JS) of the applet tag after the page loaded, once all the Fiddler activity slowed down. The element gets written to the document (and I can see the 100x100 Java error window), but not a single request shows up on Fiddler.

在我爬到角落里哭着睡觉之前,有什么建议吗?

Any suggestions, before I go crawl into the corner and cry myself to sleep?

从 Java 控制台,如果我点击l"(el) 到转储类加载器列表",我会看到如下所示的内容:

From the Java console, if I hit "l" (el) to "dump classloader list", I see something that looks like this:

Live entry: key=http://localhost:55446/BaseWebSite/,http://localhost:55446/BaseWebSite/applet/myappliet.jar, http://localhost:55446/BaseWebSite/applet/applet_dependency.jar, refCount=1, threadGroup=sun.plugin2.applet.Applet2ThreadGroup[name=http://localhost:55446/BaseWebSite/-threadGroup,maxpri=4]

编辑 2:小程序做了一些网络(Jabber/XMPP),所以我做了一个自签名证书,看看是否有帮助.收到有关自签名证书的提示 - 所以它正在读取一些东西 - 但仍然不起作用.它没有出现在 Java 缓存文件列表中......而且在 Fiddler 上仍然没有.

EDIT 2: The applet does some networking (Jabber/XMPP), so I did a self-signed cert to see if that helped. Get prompted regarding the self signed cert - so it's reading something - but still doesn't work. And it is not showing up in the Java cache file list... and still nothing on Fiddler.

推荐答案

事实证明我的问题实际上是多个问题的组合.我会暂时解决一个,但由于那不起作用(因为还有其他问题),我会返回并尝试另一种方法.

It turns out my problem was actually a combination of problems. I would temporarily solve one, but since that didn't work (since there were other problems), I would revert back and try another approach.

我在这里尝试了很多不同的方法,我不确定确切的修复方法是什么.但是,我认为它归结为

I've tried so many different things here that I'm not sure what the exact fix was. But, I think what it boiled down to was

1) 由于我的小程序使用网络组件 (Jabber/XMPP),因此需要对其进行签名.

1) Since my applet uses networking components (Jabber/XMPP), it needed to be signed.

2) 尽管在我测试的早期我确认 jar 文件以正确的方式打包,Applet.class 位于根目录,但后来在我的调试中我创建了一个 NAnt 构建脚本来简化构建/为我签署/部署流程.这个构建脚本从一个工作目录打包 jar,该目录不是应用程序的根目录.因此,AppletClient.class 不再位于根目录中,而是嵌套在 sever 子目录中.

2) Even though early on in my testing I confirmed that the jar file was packaged in the correct fashion, with the Applet.class at the root, later on in my debugging I created a NAnt build script for simplifying the build/sign/deploy process for me. This build script was packaging the jar from a working directory that was not the root of the application. So, the AppletClient.class was not at the root anymore, but nested in sever subdirectories.

这篇关于Java Applet 部署,ClassNotFoundException(主类)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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