开发者

Java Applet Deployment, ClassNotFoundException (primary class)

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

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>

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).

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).

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.

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

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.

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.

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?

EDIT: 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]

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.


I think the Java Plugin has its own cache you might want to try and empty. I'm running Windows, I find it in my control panel. In the general tab, there's a Temporary Internet Files section, see if you can find something there?

In the settings dialog, I can see the location of the cached .jars on my hard drive, and I've had to nuke it manually on a few occasions.

Also, make sure to clear the classloader cache by pressing x in the console.

Just to make sure, is AppletClient really in the default classpath, i.e. not in a package? If not, you would need to reference the qualified class name in your markup (code="your.package.AppletClient").

UPDATE:

Out of specific suggestions at this point, what you could do unless you already have is to try another markup style and just see if anything changes. Here's something I've used:

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="380" height="260">
    <param name="code" value="AppletClient" />
    <param name="archive" value="applet/myapplet.jar,applet/applet_dependency.jar" />
    <comment>
        <embed
            code="AppletClient.class"
            type="application/x-java-applet;version=1.6"
            archive="applet/myapplet.jar,applet/applet_dependency.jar"
            width="380"
            height="260">
            <noembed>No Java Support.</noembed>
        </embed>
     </comment>
</object>


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) Since my applet uses networking components (Jabber/XMPP), it needed to be signed.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜