views:

126

answers:

3

hey guys,

this is homework stuff, but the question is not much about coding. the task is to write a java applet to work on an m-grid server. i have the server running on apache. it has a few sample applets in .jar and .class form. the .class versions work; the .jar versions work on appletviewer, but they break if I submit them as a job to the server with this:

load: class examples/pixelcount/PixelCount.class not found.
java.lang.ClassNotFoundException: examples.pixelcount.PixelCount.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)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: examples.pixelcount.PixelCount.class

I'm not really sure where exactly is the problem in here, given that they work on appletviewer. any help would be appreciated..

EDIT:

don't know if I wrote it clearly. by ".class version" i refer to html file with this content:

<applet height="300" width="450" code="examples/pixelcount/PixelCount.class"></applet>

and ".jar" with this content:

<applet height="300" width="450" archive="PixelCount.jar" code="examples.pixelcount.PixelCount.class"></applet>

EDIT2:

the mentioned example jar file can be found here

A: 

The PixelCount class is not packaged in your jar I think.

And as the error is Caused by: java.net.ConnectException: Connection refused: connect it might be that it tried to obtain that class from the net somewhere, and the location does not match or a proxy is in between.

EDIT

You do have the archive someplace the m-server, whatever that may be, can find it? See the Java Applet Tag ref. docs. You may need something like

CODEBASE = codebaseURL
This OPTIONAL attribute specifies the base URL of the applet--the directory 
that contains the applet's code. If this attribute is not specified, then the 
document's URL is used.

The CODE is relative to the base URL of the document which holds the applet tag. If you want to override that you might need that CODEBASE parameter.

extraneon
i added a link to the jar file - it would seem to me that the .class is there... and as i said, it works on appletviewer.
scoobi_doobi
although I am a bit puzzled by the connection error. the server is running on localhost, and is accessible and works all fine.
scoobi_doobi
@scoob_doobi updated my answer. It may be helpful, or it might be so much hot air.
extraneon
A: 

It can't find the file PixelCount.class, its not in the directory examples/pixlecount that's why this error is happening.

Dean
as I said, this is an example provided with the server. all the other examples behave just the same. it would seem obvious it is not the problem of the examples themselves, but rather my environment.
scoobi_doobi
A: 

Don't include the .class extension in the code attribute.

examples.pixelcount.PixelCount is the name of the class.
examples.pixelcount.PixelCount.class is the name of the file that contains the class.

The code attribute should read

code="examples.pixelcount.PixelCount"
Devon_C_Miller
sorry, i didn't write it clearly. both html versions work (the top one in a browser, the bottom one in both browser and appletviewer). it is only when I submit the plain .jar file referenced in the second example to the server that it breaks. Although it is a valid comment nonentheless :-)
scoobi_doobi
No, the class extension is supposed to be there (although incorrect values may be accepted by some [broken] implementations). http://java.sun.com/javase/6/docs/technotes/guides/deployment/deployment-guide/applet.html
Tom Hawtin - tackline