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

<?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 use hibernate 4 spring 3 maven 3, I have this configuration file, and here I use the local factory session and it compiles correctly, but it gives an error when I use the JBoss server to deploy it, the server console gives the error message "configurationClass" not writable or has an invalid setter method. Does the type of the setter parameter match the return type of the receiver? help me deal with this problem

+6
source share
1 answer

The bean definition indicates that you are trying to configure Hibernate 3, not Hibernate 4. You have probably completed the wrong example or tutorial. Hibernate 4 does not have a configurationClass property. Just delete 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 do not need to provide XML configuration. All you can do is specify packages to scan for @Entity classes:

  <property name="packagesToScan" value="com.ecom.data.access.model" /> 
+13
source

Source: https://habr.com/ru/post/947359/


All Articles