tags:

views:

1392

answers:

2

I am new to Hibernate and attempting to run a java/spring example that retrieves data from a table in MS SqlServer. Everytime I try to run the program, the data source loads ok. But when spring tries to load the session facotry it gets the following error:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'sessionFactory' 
        defined in class path resource [ml/spring/src/applicationContext.xml]: 
Instantiation of bean failed; nested exception is
    java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
    Caused by: java.lang.NoClassDefFoundError: javax/transaction/TransactionManager

Below is the application Context file I am using:

<!-- Data source bean -->
<bean id="dataSource" 
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"  >
    <property name="driverClassName">
        <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value></property>
    <property name="url">
        <value>jdbc:microsoft:sqlserver://machine:port</value></property>
    <property name="username"><value>user</value></property>
    <property name="password"><value>password</value></property>
</bean>

<!--  Session Factory Bean -->
<bean id="sessionFactory" 
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource"><ref local="dataSource"/></property>
    <property name="mappingResources">
    <list>
        <value>authors.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
        <value>
            hibernate.dialect=net.sf.hibernate.dialect.SQLServerDialect
        </value>
    </property> 
</bean>

<bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
 <property name="sessionFactory" ref="sessionFactory" />
</bean>
+3  A: 

You are missing a JAR file containing the JTA API classes. You probably have one already when you downloaded Hibernate. It should be called something like:

jta-1.1.jar

Hope this helps.

toolkit
A: 

that fixed it. thanks very much.

you're welcome :-)
toolkit