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
Thanks,
-Arun
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>
>
>
--
Need Application Server ? Download from http://glassfish.org
Blog: http://blogs.sun.com/arungupta