views:

183

answers:

2

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.

A: 

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>
Lauri Lehtinen
I cleared the Java cache (nice tip!) but still no luck, and still no activity on fiddler for jars. And no, the AppletClient is not in a classpath.
Matt
What I meant to say was no, AppletClient is not in a package. It has no package, and is at the root of the first jar listed in the archive.
Matt
THanks for the help Lauri. Still no luck on my end :(. I signed the code with a self-signed cert, because it has some networking code in it that wants to be signed. I get prompted regarding the self-signed cert, so it sees that much, but still doesn't load.
Matt
And it's not showing up in the Java cache, at all. It's like the files aren't getting loaded at all.
Matt
Tough one huh! Do other applets work? Yours, others'? The one on http://www.pdfcombine.com for example? I once disabled the Java plugin in my browser to test how a site functioned with no Java support, and it screwed something up so bad I had to re-install both the public JRE and the browser to get it back to a working state. I can't remember if it was browser specific, it was my main browser (Firefox) so I had no choice anyway. Just an FYI. When you figure this one out, make sure to post the solution here, I really want to know.
Lauri Lehtinen
Yeah, Java Applets work on other sites. Just tried http://richardbowles.tripod.com/java/mandel.htm. Another weird thing - an old version of this applet (jar) works fine. It is of course old and buggy, hence the update. But I unpacked it and it has the same dir/file structure (and hence location of the AppletClient.class) as the one that's not loading
Matt
A: 

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.

Matt