Spring 3, Hibernate, JPA

1 resposta
Fox_McCloud

Estou tentando configurar aqui Spring 3, Hibernate e JPA usando a própria especificação do Spring como referência, mas ao subir a aplicação dá erro:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryRH' defined in ServletContext resource [/WEB-INF/spring/hibernate-beans.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No PersistenceProvider specified in EntityManagerFactory configuration, and chosen PersistenceUnitInfo does not specify a provider class name either

Esse bean específico está nesse xml:

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

	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false">
		<property name="ignoreUnresolvablePlaceholders" value="true"/>
		<property name="ignoreResourceNotFound" value="true"/>
		<property name="location" value="file:${JBOSS_HOME}/server/jbpm/conf/rh-jdbc.properties"/>
	</bean>

	<bean id="dataSourceRH" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="${jdbc.driverClass}"/>
		<property name="url" value="${jdbc.jdbcUrl}"/>
		<property name="username" value="${jdbc.user}"/>
		<property name="password" value="${jdbc.password}"/>
		<property name="initialSize" value="${jdbc.minPoolSize}"/>
		<property name="maxActive" value="${jdbc.maxPoolSize}"/>
		<property name="maxWait" value="${jdbc.maxIdleTime}"/>
	</bean>

	<bean id="entityManagerFactoryRH" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSourceRH"/>
		<property name="persistenceXmlLocation" value="classpath:META-INF/persistence-rh.xml"/>
		<property name="loadTimeWeaver">
			<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
		</property>
	</bean>
	
</beans>
E o persistence-rh.xml é o seguinte:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
	<persistence-unit name="persistenceRH" transaction-type="JTA">
	</persistence-unit> 
</persistence>
Sujestões?

1 Resposta

K

Cara…
vc nao declarou o

<?xml version="1.0" encoding="UTF-8"?>  
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">  
    <persistence-unit name="persistenceRH" transaction-type="JTA">  

<provider>org.hibernate.ejb.HibernatePersistence</provider>

    </persistence-unit>   
</persistence>

dentro do seu persistence.xml, confere se funciona.

[]s

Criado 12 de novembro de 2010
Ultima resposta 7 de abr. de 2011
Respostas 1
Participantes 2