smith February 2016

org.springframework.beans.TypeMismatchException

getting the type mismatch exception. My project is spring and hibernate integration and i am getting error as

Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.lang.Class[]' for property 'annotatedClasses'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.vrnda.hibernatemappingfile.ProjectDetails]

sdnext-servlet.xml is

<?xml version="1.0" encoding="UTF-8"?>
< beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
  xsi:schemaLocation="
  http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-3.0.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
 http://www.springframework.org/schema/mvc 
 http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
 http://www.springframework.org/schema/jee 
 http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
 http://www.springframework.org/schema/data/mongo
            http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">

<context:component-scan base-package="com" />



<tx:annotation-driven transaction-manager="hibernateTransactionManager"/>  
<mvc:annotation-driven /> 
<mvc:resources mapping="/images/**" location="/images/**" cache-period="31556926"/>
<mvc:resources mapping="/scripts/**        

Answers


We are Borg February 2016

Are you using Hibernate 3 or Hibernate 4? If 3, then is it an old project and you have to use 3? This is my configuration for 4 and it works :

 <beans:bean id="hibernate4AnnotatedSessionFactory"
                class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <beans:property name="dataSource" ref="dataSource"/>
        <beans:property name="packagesToScan" value="com.journaldev.spring.model"/>

The value above just gives the path to the package where all Model files are. Rest is handled by Spring. Try this out, and check why are you using Hibernate 3.

Post Status

Asked in February 2016
Viewed 3,528 times
Voted 7
Answered 1 times

Search




Leave an answer