ClassNotFoundException with Applet and Servlet
From: Phil Powell (soazine_at_erols.com)
Date: 02/28/04
- Previous message: Boniface Frederic: "Re: Applet compilation pb"
- Next in thread: Ryan Stewart: "Re: ClassNotFoundException with Applet and Servlet"
- Reply: Ryan Stewart: "Re: ClassNotFoundException with Applet and Servlet"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Feb 2004 01:47:17 -0800
I have a servlet, NicknameServlet, that is connected via OutputStream
-> HttpURLConnection object chain from an applet.
For some bizarre reason, though, the APPLET throws a
ClassNotFoundException error (and not the servlet!)
java.lang.ClassNotFoundException: ppowell.NicknameBin
However, the Applet, not one time, ever addresses even remotely that
class. In its method populateNickArray() though there is that
OutputStream -> HttpURLConnection object to the servlet that itself
instantiates a NicknameBin object.
If you call the Servlet directly you should receive a serialized
Vector object:
http://www.myjavaserver.com/servlet/ppowell.NicknameServlet
Here is the code to the Servlet:
[Code]
/**
* @version JSDK 1.2
* @author Phil Powell
*/
package ppowell;
import java.io.*;
import javax.servlet.*;
import java.util.Vector;
import javax.servlet.http.*;
/**
* This servlet will retrieve the server's JVM-run Singleton instance
of NicknameBin
* originally instantiated when the user went through
chat_validation.jsp
*
* @see ChatGlobals, NicknameBin, ChatClient
*/
public class NicknameServlet extends HttpServlet implements
Serializable {
public NicknameServlet() {}
public void doGet(HttpServletRequest request, HttpServletResponse
response) {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse
response) {
NicknameBin nickBin = NicknameBin.getNicknameBin(); // CREATE OR
REFER TO SINGLE INSTANCE
try {
// DELIVER ENTIRE NICKNAMEBIN AS IS
ObjectOutputStream out = new
ObjectOutputStream(response.getOutputStream());
out.writeObject((Object)nickBin);
out.flush();
out.close();
out = null;
} catch (IOException e) {
System.out.println("Could not retrieve NicknameBin instance");
e.printStackTrace();
} catch (Exception idunno) {
idunno.printStackTrace();
}
}
}
[/Code]
My question is this: How is it possible for an Applet, that I assume
is running on your own JVM on your machine, reference a class on a
remote server running via its own JVM, when there is no direct
reference to that class from the applet whatsoever? Why is it when
you call the servlet directly everything's just fine; when you call it
via the applet you get such a non-sequitur seeming error?
Thanx
Phil
- Previous message: Boniface Frederic: "Re: Applet compilation pb"
- Next in thread: Ryan Stewart: "Re: ClassNotFoundException with Applet and Servlet"
- Reply: Ryan Stewart: "Re: ClassNotFoundException with Applet and Servlet"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|