Java.lang.NullPointerException ao injetar o @PersistenceUnit -RESOLVIDO

1 resposta
E

Pessoal estou com um problema aqui

tenho minha calsse dao

public class Dao {

	@PersistenceUnit(unitName="ControleFotoPU")
	protected EntityManagerFactory emf;
	protected EntityManager em;

	public Dao() {
	}
...........................
}

arquivos de configurações

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/controlefoto</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>

persistence

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="ControleFotoPU">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
			<property name="hibernate.ejb.cfgfile" value="/META-INF/hibernate.cfg.xml" />
        </properties>
</persistence-unit>
</persistence>

Obs: os arquivos de configurações estão dentro de META-INF EM SORUCE

, porem nao hora de injetar o emf , ele não injeta e da nullpointer

alguem sabe o que pode ser?

1 Resposta

E

ah - eu não estou usando ejb…por isso não funciona né?

ID só funciona do contexto de EJB…

desculpa de post

Criado 16 de março de 2011
Ultima resposta 16 de mar. de 2011
Respostas 1
Participantes 1