• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Argh....all I want to do is load this applet..

 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to load an applet I wrote from a web page (JSP). It will load just fine when I do it locally inside an HTML page, but when I try accessing it from the web server it says that the applet cannot be found.

Here is what I have:




The page loads fine but the applet will not load because it cannot find the DisplayMonoApplet.class.

Here is the exact error:

load: class DisplayMonoApplet.class not found.
java.lang.ClassNotFoundException: DisplayMonoApplet.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more

My DisplayMonoApplet can be found in the WAR file in the following location:
WEB-INF\classes\myapp\DisplayMonoApplet.class

I have tried every configuration I can think of (myapp/DisplayMonoApplet, http://myserver:18080/myapp/.....etc.) but no luck.

I've tried using a CODEBASE too but still no luck.

Please help me find out what I'm doing wrong before I go insane!

THANKS!
[ May 06, 2005: Message edited by: Darrin Smith ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The applet class files are requested directly from the webserver by the browser. Therefore, they have to be in publically accessible web space. They cannot be anywhere inside of WEB-INF, because this directory is quite deliberately not served from.

Basically, the applet class files need to be at the top level of the web app, or in a jar file at some stated path below that top level -- but not in WEB-INF.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so I need to move the applet outside of WEB-INF.

So for example, if I place it in my C:\web_app directory, then to get to it all I need to do is:

CODE = "DisplayMonoApplet.class"
CODEBASE = "http://myservermachine/"

It will still be in the WAR file, just not under the WEB-INF directory then.

Is this right?

THANKS!!!
[ May 07, 2005: Message edited by: Darrin Smith ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, sounds good.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, being at home I couldn't try the actual case decribed above, but I worked up a quick test using the old Applet tag and not loading the plugin and did a quick HelloWorld style applet, and sure enough as you thought, it works when I put the applet at the top (not inside the web-inf)!

On Monday I'll convert what I have at work to the way you suggest and see if it still works with the extra plugin code and all.

I've never distributed an applet (servlets yes...plenty of those) through a web server before and didn't know it was restricted that way.

MANY THANKS!
 
Sudha Rams
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. This works!!
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Am I doing anything wrong, or does it just hate me?


Note that the commented out plugin command was the way it looked (and worked) before I placed the applet and its supporting classes inside the jar file.

Thanks!
[ May 20, 2005: Message edited by: Darrin Smith ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For jar files, you need to drop the "codebase" attribute and use "archive" instead. "Codebase" signifies a directory full of loose classes only.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
For jar files, you need to drop the "codebase" attribute and use "archive" instead. "Codebase" signifies a directory full of loose classes only.


Doh!!

I guess that is why I couldn't find much when I serache for codebase being used with jar files in plugins.

I'll change codebase="http....." to archive="http:...." and give it a try.

Thanks!
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, that did it!

I really appreciate it!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic