[mybatis-spring] MalformedParameterizedTypeException and 'sqlSessionFactory

487 views
Skip to first unread message

Jose María Zaragoza

unread,
Mar 5, 2013, 11:56:31 AM3/5/13
to mybati...@googlegroups.com
Hello:

When I deploy my web applicaton , I'm getting the next error

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sqlSessionFactory' defined in ServletContext
resource [/WEB-INF/jdbc-context.xml]: Initialization of bean failed;
nested exception is
java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:526)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)


I've read that it could be about version conflicts between mybatis ,
spring and mybatis-spring , but I've tried to change them and it
doesn't work


These are my Maven dependences

<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.1.0</version>
</dependency>


<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.0.2</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>


This is my Spring context


<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url"
value="jdbc:sqlserver://xxxxx=yyyy;databaseName=zzzzz" />
<property name="username" value="aaaaaaaa" />
<property name="password" value="xxxxxxxx" />


<tx:annotation-driven transaction-manager="txmanager" />

<!-- Declare a transaction manager -->

<bean id="txmanager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>



<!-- Define the SqlSessionFactory, Notice that configLocation is not
needed when you use MapperFactoryBean -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="WEB-INF/sqlmap-config.xml" />
</bean>

<!-- Scan for mappers and let them be @Autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.example.server.persistence.mapper" />
</bean>


Thanks and regards

Eduardo Macarron

unread,
Mar 5, 2013, 1:03:03 PM3/5/13
to mybati...@googlegroups.com
Hola Jose María,

Usually that exception is thrown when you mix several versions of Spring.

Note that you need at least mybatis-spring 1.1.0 to work with MyBatis
3.1.0. So upgrade at least to that version.

Then, if the problem persist, type mvn dependency:tree in your
projects root to see where is the wrong dependency.

HTH

Jose María Zaragoza

unread,
Mar 6, 2013, 8:53:12 AM3/6/13
to mybati...@googlegroups.com
2013/3/5 Eduardo Macarron <eduardo....@gmail.com>:
Thanks Eduardo.
I had got the right versions but I had to run 'mvn clean' for fixing it


Regards
Reply all
Reply to author
Forward
0 new messages