• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to set up Hibernate Session Factory

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying create a sample application using WebSphere V5.1 and Hibernate V 3.1. I've set up a datasource that connects to an Oracle Express 10g database. I've followed the instructions in Thiis WebSphere Developer Tech Journal Article. When I try to initialize the Hibernate session factory, I get the following error:

[4/5/06 17:29:30:844 PDT] 33782bdf TransactionFa I org.hibernate.transaction.TransactionFactoryFactory Transaction strategy: org.hibernate.transaction.WebSphereTransactionManagerLookup
[4/5/06 17:29:30:844 PDT] 33782bdf WebSphereTran I org.hibernate.transaction.WebSphereTransactionManagerLookup WebSphere 5.1
[4/5/06 17:29:30:844 PDT] 33782bdf WebGroup I SRVE0181I: [HibernateSample] [/HibernateSample] [Servlet.LOG]: action: null: java.lang.ClassCastException: org.hibernate.transaction.WebSphereTransactionManagerLookup
at org.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:37)
at org.hibernate.cfg.SettingsFactory.createTransactionFactory(SettingsFactory.java:370)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:120)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at com.sample.util.HibernateStrutsPlugIn.init(HibernateStrutsPlugIn.java:40)
... more lines in stack trace


This error occurs on this line of code:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

here is my hibernate.cfg.xml file:
<hibernate-configuration>
<session-factory name="HybernateSessionFactory">
<property name="transaction.factory_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="connection.datasource">jdbc/oracleXE</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hbm2ddl.auto">create</property>
<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
<mapping resource="address.hbm.xml"/>
<mapping resource="phone.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Anyone have an idea why this class cast exception is occurring?
[ April 05, 2006: Message edited by: Merrill Higginson ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was able to get this working by chaging the following line in hibernate.cfg.xml:

<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>

I guess the information in the original tutorial was old.
[ April 05, 2006: Message edited by: Merrill Higginson ]
reply
    Bookmark Topic Watch Topic
  • New Topic