Good morning all.  I am a stodgy old VB, COM, ASP, C++ programmer and am
trying to convert to a hip, young Java type.  I am pushing through the first
chapters of "Professional Java Server Programming" published by Wrox.  I
tried using Apache Server and the Sun SDK directly but found better luck
using Netscape's Fastrack server to test some of these Servlet examples.   I
believe I finally have the server configured right and am trying to use
persistent storage in a servlet context that is launched on server startup.
The application is a sample chat room program.  However when this code is
executed later:


RoomList roomList = (RoomList) getServletContext().getAttribute("roomList");

The web page gives this:

Server Error
This server has encountered an internal error which prevents it from
fulfilling your request. The most likely cause is a misconfiguration. Please
ask the administrator to look for messages in the server's error log.

And the server's error log shows this:

[27/Oct/2000:07:26:17] failure ( 1524): Internal error: exception thrown
from the servlet service function (uri=/ListRooms):
java.lang.ClassCastException, Stack: java.lang.ClassCastException
        at
com.wrox.context.chat.ListRoomsServlet.writePage(ListRoomsServlet.java,
Compiled Code)
        at
com.wrox.context.chat.ListRoomsServlet.doGet(ListRoomsServlet.java:32)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:701)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:826)
        at
com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.jav
a:502)


I put this code before it to determine the class because I assumed (as a C++
guy) that there is some sort of casting error:

      Object ob = getServletContext().getAttribute("roomList");
     if(ob==null)
      {
          out.println("Not set!");
      }
      else
      {
          out.println(ob.getClass().toString());
      }

which results in:

 class com.wrox.context.chat.RoomList


which is the type defined.   Anyone have any ideas to keep me from chucking
my Java books out the 9th story window potentially hurting potential
customers ???

BTW,  I assumed this wasn't covered in a SUN FAQ, so I hope this isn't too
junior a question.


Regards,

Karl D. Parker
Core Technologies
RetailDNA, LLC
<<http://www.walkerdigital.com/Companies/companies.cfm?screen_id=4.3>> - A
Walker Digital Company

One Stamford Plaza
Stamford, CT 06902
203-564-1458 | 203-564-1772 (fax) | 330-8051272 (cell)
This message, together with any attachments, is intended only for the use of
the individual or entity to which it is addressed and may contain
information that is legally privileged, confidential, and exempt from
disclosure. If you are not the intended recipient, you are hereby notified
that you have received this message in error; any review, dissemination,
distribution, or copying of this message, or any attachment, is strictly
prohibited. If you have received this message in error, please delete this
message and any attachments from your computer and immediately notify the
original sender at (203) 564-1432 or by return e-mail. Thank you

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to