JPA 2.0 + Spring 3 + Maven - The user must supply a JDBC connection [RESOLVIDO]

1 resposta
renanjp

Galera, estou configurando um ambiente aqui e me deparei com este erro…

java.lang.UnsupportedOperationException: The user must supply a JDBC connection
javax.faces.el.EvaluationException: java.lang.UnsupportedOperationException: The user must supply a JDBC connection

Persistence.xml no web Inf

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
	version="1.0">

	<persistence-unit name="MySQLPersistence"
		transaction-type="RESOURCE_LOCAL">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<properties>
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
			<property name="hibernate.hbm2ddl.auto" value="update" />
			<property name="hibernate.show_sql" value="true" />
			<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
			<property name="javax.persistence.jdbc.user" value="root" />
			<property name="javax.persistence.jdbc.password" value="masterkey" />
			<property name="javax.persistence.jdbc.url" value="jdbc:mysql://189.29.30.233:3306/teste" />
		</properties>
	</persistence-unit>
</persistence>

Aplication context

<?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:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop"
	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/aop  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

	<tx:annotation-driven />

	<context:annotation-config />

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

	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>
	
	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceUnitName" value="MySQLPersistence" />
	</bean>
	
	<bean class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>
	
</beans>

Operação:

@PersistenceContext
	private EntityManager entityManager;

@Override
	public T findById(Serializable id) {
		return this.entityManager.find(getPersistentClass(), id);
	}

Alguem poderia me dar uma luzz :slight_smile:

Abraçoss!!

1 Resposta

renanjp

Resolvi…

Troquei os “javax.persistence.” por “hibernate.” e funfou…

vai entender!!
AHEHAEHEHAEH

:lol:

Criado 2 de novembro de 2012
Ultima resposta 3 de nov. de 2012
Respostas 1
Participantes 1