2 Replies Latest reply on Aug 27, 2009 8:38 AM by -==cfSearching==-

    CF8 with Java CFX / Hibernate - ClassCastException

    Andy Thornton



      I don't know if anyone can throw any light onto this?  I have a bunch of Java code that uses Hibernate to interact with the database. I am trying to put a CF web front on to display some information.  I wrote a very small Java CFX as a gateway into my Java codebase.  Somewhat surprisingly to me it was actually very easy to get it more-or-less working.  In fact, if I use non-generics code I can display values straight from my database onto a webpage.


      I have a valid Hibernate Query object that I call .list on.  The list contains Country objects (say).  If I loop over the list as 'objects' and ay call the toString method (which in turns calls Country specific methods) it works fine, however if I try and cast to a Country object I get a ClassCastException saying it cannot cast Country to Country.


      The only thing I can think of is that the 'two' Country classes (conceptually they is just a single class, of course) cannot be cast to each other because they were loaded by different classloaders.


      Anyone have any idea?





      I am using CF8, Java 1.6 and Hibernate 3.