Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to return applet using servlet

0 views
Skip to first unread message

JACKSON

unread,
Jul 21, 2003, 11:23:40 PM7/21/03
to
I am trying to use servlet to load a applet, but java console shows
java.lang.ClassFormatError, how to solve this problem? thanks alot.

Jackson

Here is part of my servlet code:
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>");
out.println("Chat and Share Community");
out.println("</title>");
out.println("</head>");
out.println("<body>");
out.println("<applet");
out.println("codebase = \".\"");
out.println("code = \"Editor.class\"");
out.println("name = \"Editor\"");
out.println(">");
out.println("</applet>");
out.println("</body>");
out.println("</html>");

Here is the error msg in Java Console:
java.lang.ClassFormatError: Editor (Truncated class file)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:502)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:148)

at
sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:168)

at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)

at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)

at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)

at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1775)

at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)

at sun.applet.AppletPanel.run(AppletPanel.java:293)

at java.lang.Thread.run(Thread.java:536)

John C. Bollinger

unread,
Jul 21, 2003, 11:59:18 AM7/21/03
to
JACKSON wrote:
> I am trying to use servlet to load a applet, but java console shows
> java.lang.ClassFormatError, how to solve this problem? thanks alot.

This error generally means that an attempt was made to load a class
whose bytecode has been corrupted, or that isn't a class at all. It
doesn't look like the servlet code has anything to do with it. Create a
static page to test with, to take the servlet out of the picture, then
work out the problem with the applet's class. The most common causes
are (1) the applet class was corrupted during file transfer (e.g. via
FTP in ASCII mode) and (2) the putative .class file is a copy of the
.java file rather than compiled bytecode.

[stack trace elided]


John Bollinger
jobo...@indiana.edu

Roedy Green

unread,
Jul 21, 2003, 2:37:55 PM7/21/03
to
On Mon, 21 Jul 2003 20:23:40 -0700, "JACKSON" <sun...@singnet.com.sg>
wrote or quoted :

>I am trying to use servlet to load a applet, but java console shows
>java.lang.ClassFormatError, how to solve this problem? thanks alot.

I have always had better luck packaging Applets in Jars. Try that.
The error message literally says the server failed to deliver the
entire class file.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

0 new messages