atom feed7 messages in net.java.dev.glassfish.usersRe: problems loading EntitymanagerFac...
FromSent OnAttachments
Felipe GaúchoFeb 25, 2010 12:19 pm 
Arun GuptaFeb 25, 2010 12:27 pm 
Felipe GaúchoFeb 25, 2010 12:29 pm 
Felipe GaúchoFeb 25, 2010 12:32 pm 
Felipe GaúchoFeb 25, 2010 12:47 pm 
Felipe GaúchoFeb 25, 2010 12:57 pm 
Arun GuptaFeb 25, 2010 1:47 pm 
Subject:Re: problems loading EntitymanagerFactory wih CDI in GFv3
From:Felipe Gaúcho (fgau@gmail.com)
Date:Feb 25, 2010 12:29:17 pm
List:net.java.dev.glassfish.users

yes, I read your blog.. and you use:

@Named("sakilabean") @RequestScoped public class SakilaBean { @PersistenceUnit(unitName="SakilaPU") EntityManagerFactory emf;

so it is supposed to work...

* if I change the bean to ManagedBean, than the index.xhtml cannot find it anymore and I have a null reference.............

On Thu, Feb 25, 2010 at 9:28 PM, Arun Gupta <Arun@sun.com> wrote:

Felipe,

I assume you made sure persistence.xml is bundled in the WAR file :-)

Also, try changing @Named to @ManagedBean and see if that works. Lets make sure that the basic scenario works in your environment.

BTW, I blogged about this exact scenario at:

http://blogs.sun.com/arungupta/entry/totd_123_f_ajax_bean

Felipe Gaúcho wrote:

I am trying to use CDI to deploy a web-application based on JSF 2 & JPA 2....

but it fails to inject the EntityManagerFactory:

Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName arenapuj2        at com.sun.enterprise.container.common.impl.EntityManagerFactoryWrapper.getDelegate(EntityManagerFactoryWrapper.java:91)

---------- bean:

import java.util.Collection;

import javax.enterprise.context.RequestScoped; import javax.inject.Named; import javax.persistence.*;

import com.kenai.puj.arena.model.entity.PujInstitutionEntity;

@Named("institutions") @RequestScoped public class PujInstitutionBean {        @PersistenceUnit(unitName = "arenapuj2")        EntityManagerFactory emf; ...

---------- persistence.xml

<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0"        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_2_0.xsd">        <persistence-unit name="arenapuj2" transaction-type="JTA">

 <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>                <jta-data-source>jdbc/arena</jta-data-source>                <properties>                        <property name="eclipselink.ddl-generation" value="none" />                        <property name="eclipselink.logging.level" value="FINEST" />                </properties>

       </persistence-unit> </persistence>