At attempt of start falls with an error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [application- context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy 

application-context.xml:

 <?xml version="1.0" encoding="UTF-8"?> 

http://www.springframework.org/schema/beans/spring-beans.xsd ">

 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:db.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${db.driver}"/> <property name="url" value="${db.url}"/> <property name="username" value="${db.user}"/> <property name="password" value="${db.password}"/> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="typeAliasesPackage" value="com.rest.service.entity" /> </bean> <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="mapperInterface" value="com.rest.service.mapping.UserMapper" /> <property name="sqlSessionFactory" ref="sqlSessionFactory" /> </bean> 

I don’t understand what’s wrong here, I’m doing this: http://www.mybatis.org/spring/getting-started.html

The context is initialized as follows:

 public class ApplicationInitializer implements WebApplicationInitializer { private static final String DISPATCHER = "dispatcher"; public void onStartup(ServletContext servletContext) throws ServletException { XmlWebApplicationContext appContext = new XmlWebApplicationContext(); appContext.setConfigLocation("classpath:application-context.xml"); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER, new DispatcherServlet(appContext)); dispatcher.addMapping("/"); dispatcher.setLoadOnStartup(1); } } 

What could be the problem?

  • Maybe try to run the whole thing in Java 8? Check if the spring-jdbc.jar - Xoxole library is connected to the project

1 answer 1

The problem was solved by adding the spring-jdbc dependency to pom.xml