Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ClassNotFoundException hell for applet

Status
Not open for further replies.

bthale

Programmer
Oct 31, 2001
108
US
I have tried about everything. Here is my applet tag. I have tried the code parameter with forward slashes and dot notation. Any help appreciated. The class is in the WEB-INF/classes folder under the webapp on the server, so That should be the spot.

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="20" height="20" name="printerApp" archive="applet.jar"
codebase=" <param name="code" value="tarrant/civil/applets/PrinterApplet.class"/>
<param name="selectedIds" value=""/>
<param name="MAYSCRIPT" value="true">
<comment>
<embed code="tarrant/civil/applets/PrinterApplet.class" archive="applet.jar"
width="0" height="0" mayscript="true" name="printerApp"
type="application/x-java-applet;version=1.5.0"
pluginspage=" <noembed>
No Java Support.
</noembed>
</embed>
</comment>
</object>
 
The class name is tarrant.civil.applets.PrinterApplet which is what I have specified in the code parameter. Are you saying remove the .class?

 
You were right about removing .class, but it still doesn't work. I found the exception is cause by IOException. Not sure what this means.

Caused by: java.io.IOException: open HTTP connection failed: 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: WEB-INF.classes.tarrant.civil.applets.PrinterApplet.class
 
I found out that it is necessary to put the applet jar file(s) in a place where the client can find it, which is not under WEB-INF. I have the follwing directory structure under Tomcat

webapps/myapp/applets

I placed the applet jar file there and used the following tags but still doesn't work.

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="20" height="20" name="PrinterApp" archive="applet.jar"
codebase="applets/">
<param name="code" value="tarrant.civil.applets.PrinterApplet"/>
</object>

Mayber I just don't understand what codebase, code, and archive is doing, but I have tried every combination I could think of to no avail. I even exploded the jar under applets directory. I don't understand why this isn't straight forward. One post I saw said to simply put it into my webapp root directy and use codebase="*" archive="applet.jar", code="tarrant.civil.applets.PrinterApplet" which seems to me should work, but doesn't.

Any help appreciated.
 
[0] Suppose the directory structure be this:
[tt]
webapps-|
|-- your_web_page.html
|-myapp-|
|--applet.jar
[/tt]
[1] The object tag looks like this (for ie portion).
[tt]
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="20" height="20" name="PrinterApp">
<param name="selectedIds" value="" />
<param name="MAYSCRIPT" value="true" />
<param name="code" value="tarrant.civil.applets.PrinterApplet.class" />
<param name="codebase" value="applets" />
<param name="archive" value="applet.jar" />
</object>
[/tt]
 
First: Try to bring the applet up in your local directory with the appletviewer. There you should solve issues with the classpath. Without looking at the code, we cannot decide whether your Applet is applets.PrinterApplet in the directory tarrant/civil, or civil.applets.PrinterApplet in directory tarrant, or is tarrant part of the package declaration.

Second: Generate a webpage, to view your Applet on the local machine inside the browser. Don't try randomentries, but read the documentation.

Maybe your Applet is public, and you can give us the link.

This is a simple JApplet without package-declaration, without clsid, name, archive, embed, which works for me:
Code:
<html>
	<head>
		<title> HalloJavaApplet </title>
	</head>
	<body>
		<applet
			code="HalloJavaApplet" 
			HEIGHT="640" 
			WIDTH="480"
			>
		</applet>
	</body>
</html>
Start simple, and don't add things which you don't need.

Add more things stepwise, if you need them.

don't visit my homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top