Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

property 'configurationClass' is not writable or has an invalid setter method. Does the parameter type of the setter

<?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:util="http://www.springframework.org/schema/util"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/util
            http://www.springframework.org/schema/util/spring-util-3.0.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/jee 
            http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

        <util:properties id="hibernateProperties" location="classpath:hibernate.properties" />

        <bean id="usermanagementSessionFactory"
            class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
            <property name="dataSource" ref="usermanagementDataSource" />
            <property name="configLocation" value="classpath:hibernate.cfg.xml" />
            <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
            <property name="hibernateProperties" ref="hibernateProperties" />
        </bean>

        <jee:jndi-lookup id="usermanagementDataSource" jndi-name="java:jboss/datasources/usermanagementDS" />

        <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
            init-method="init" destroy-method="close">
            <property name="forceShutdown" value="false" />
            <property name ="startupTransactionService" value="true"/>
        </bean>

        <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
            <property name="transactionTimeout" value="30" />
        </bean>

        <bean id="transactionManager"
            class="org.springframework.transaction.jta.JtaTransactionManager">
            <property name="transactionManager" ref="atomikosTransactionManager" />
            <property name="userTransaction" ref="atomikosUserTransaction" />
        </bean>

        <bean id="User" class="com.ecom.data.access.model.User"/>
        <bean id="myFactory" class="com.ecom.data.access.dao.MyFactory"/>

    </beans>

I am using hibernate 4 spring 3 maven 3, i have this configuratiobn file and here I am using local session factory and it compile correctly but it gives the error when I am using the JBoss server to deploy it then server console gives the error 'configurationClass' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? please help me to sort out this problem

like image 895
Naveen Kumar Avatar asked Jun 15 '13 09:06

Naveen Kumar


1 Answers

Your bean definition suggests that you are trying to configure Hibernate 3, not Hibernate 4. You have probably followed incorrect example or tutorial. In Hibernate 4 there is no configurationClass property. Just remove it:

<bean id="usermanagementSessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="usermanagementDataSource" />
    <property name="configLocation" value="classpath:hibernate.cfg.xml" />
    <property name="hibernateProperties" ref="hibernateProperties" />
</bean>

With Hibernate 4, you also don't need to provide configuration XML. All you can do is to specify packages to be scanned for @Entity classes:

    <property name="packagesToScan" value="com.ecom.data.access.model" />
like image 155
Pavel Horal Avatar answered Oct 27 '22 00:10

Pavel Horal