Results 1 to 2 of 2

Thread: Inheritance and ClassCastException on a Servlet

  1. #1
    Join Date
    Jun 2005
    Posts
    4

    Default Inheritance and ClassCastException on a Servlet

    Hi,

    I have two classes in my project Document and BigDocument, both are mapping with inheritance in the logic way with Hibernate. On the other hand I don't use any MVC framework so I use only plain servlets, for this reason I extend my servlets from FrameworkServlet which give me the WebAplicationContext for working with my beans in the context.xml file.

    Everything works fine when I use the base class Document, but when I use the child BigDocument I get a ClasCastException error.... pls help me!

    Consider the following code:

    Code:
    GestorCartera gestorCartera = (GestorCartera) getWebApplicationContext().getBean("gestorCartera");
    
    Documento documento = gestorCartera.seleccionarDocumento(18094818096L);
    
    BigDocument bigDocument = (BigDocument )documento;
    In the last line I get the ClassCastException....., this error don't happen when I test this code in a main method. :shock:

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Last edited by robyn; May 14th, 2006 at 10:31 AM.

Similar Threads

  1. Replies: 3
    Last Post: Sep 7th, 2005, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •