I'm new to Mybatis and trying to implement mybatis with Spring but getting the below runtime error while starting tomcat.
Here is my pom.xml
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.0.0</version>
</dependency>
and application context:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="uactivityDS"/>
<property name="configLocation" value="classpath:mybatis-config.xml"/>
</bean>
The error is:
the resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/ibatis/session/SqlSessionFactory
The mybatis-spring-1.0.0.jar
file exists in war/web-inf/lib
, though.
Any idea what's going on in this scenario?
If you look at the pom.xml for mybatis-spring-1.0.0.jar, it has a compile time dependency of mybatis 3.0.4 which contains the class org/apache/ibatis/session/SqlSessionFactory.
So include that jar as well along with others mentioned in the pom.xml and you should be good.