-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Spring and Hibernate java.lang.ClassCastException $Proxy0
PostPosted: Mon Dec 12, 2005 4:26 pm 
Newbie

Joined: Mon Oct 18, 2004 1:42 pm
Posts: 10
Location: Ottawa, Canada
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1
Spring Framework version: 1.2.5

Below is an excerpt of the Spring Context file I am using to initialize my Hibernate environment.

Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
 
   <property name="mappingResources">
         <list>
             <value>ca/gc/rcmp/nsor/domain/hibernate/Victim.hbm.xml</value>
              </list>
       </property>

      <!-- extra content omitted -->
     
</bean>




I am trying out the code below

Code:

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.hibernate.cfg.Configuration;
import org.springframework.orm.hibernate3.LocalSessionFactoryBean;


  // Code excerpt below excludes class definition and constructors.
ApplicationContext ctx =
new FileSystemXmlApplicationContext(APP_CONTEXT_FILENAME)
LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean)
                ctx.getBean("sessionFactory");
Configuration cfg = lsfb.getConfiguration();




The cast to LocalSessionFactoryBean throws a ClassCastException


Code:
Exception in thread "main" java.lang.ClassCastException: $Proxy0
   at ca.gc.rcmp.nsor.util.Remove.main(MyClass.java:36)



How do I get a reference to the LocalSessionFactoryBean as defined in the SpringContext file?

Is there another way of the getting the org.hibernate.cfg.Configuration given a SessionFactory?

Thanks.

Josh.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.