users@glassfish.java.net

Re: problems loading EntitymanagerFactory wih CDI in GFv3

From: Arun Gupta <Arun.Gupta_at_Sun.COM>
Date: Thu, 25 Feb 2010 13:47:59 -0800

Have you tried packaging your entities as a vanilla JAR file ?

-Arun

Felipe Gaścho wrote:
> now the problem is:
>
> I am deploying the entities in an ejb-jar inside the war.WEB-INF/lib folder..
>
> and when I try to do a query in one of those entities:
>
> Caused by: java.lang.IllegalArgumentException: An exception occurred
> while creating a query in EntityManager:
> Exception Description: Error compiling the query [select e from
> PujInstitutionEntity e]. Unknown entity type [PujInstitutionEntity].
> at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1328)
>
>
> 2010/2/25 Felipe Gaścho <fgaucho_at_gmail.com>:
>> stop ! I find the first mistake.. the persistence.xml was in a wrong place :)
>>
>> thanks Arun, stupid mistake but sometimes we just need a friend to
>> make the right questions :)
>>
>> now it failed one step further.. I am investigating................
>>
>> 2010/2/25 Felipe Gaścho <fgaucho_at_gmail.com>:
>>> 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.Gupta_at_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
>>>>
>>>> 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
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>>>
>>>>
>>>
>>>
>>> --
>>> ------------------------------------------
>>> Felipe Gaścho
>>> 10+ Java Programmer
>>> CEJUG Senior Advisor
>>>
>>
>>
>> --
>> ------------------------------------------
>> Felipe Gaścho
>> 10+ Java Programmer
>> CEJUG Senior Advisor
>>
>
>
>

-- 
Need Application Server ? Download from http://glassfish.org
Blog: http://blogs.sun.com/arungupta