Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2004

Tip: Looking for answers? Try searching our database.

ClassNotFoundException with Applet and Servlet

Thread view: 
Phil Powell - 28 Feb 2004 09:47 GMT
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
Ryan Stewart - 28 Feb 2004 14:03 GMT
> I have a servlet, NicknameServlet, that is connected via OutputStream
> -> HttpURLConnection object chain from an applet.
[quoted text clipped - 79 lines]
> Thanx
> Phil

You're sending an instance of NicknameBin to the Applet, right? Why would it
not need to know about it?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.