You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Phani Madgula <ph...@gmail.com> on 2008/05/28 14:37:59 UTC

Trying to create EntityManager in web application

Hi,

I was trying to obtain javax.persistence.EntityManager in a web application
as follows.

1. Created persistence.xml in META-INF folder.
__________________
<?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"
version="1.0"
                xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="CurrencyRateUnit">
        <description>JPA JSF Sample</description>

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <class>sample.jpa.currency.Currency</class>
        <properties>
            <property name="openjpa.ConnectionURL"
value="jdbc:derby:CurrencyDB" />
            <property name="openjpa.ConnectionDriverName"
value="org.apache.derby.jdbc.EmbeddedDriver" />
            <property name="ConnectionUserName" value="app" />
            <property name="openjpa.jdbc.SynchronizeMappings" value="false"
/>
        </properties>
    </persistence-unit>
</persistence>

______________________________________________________________________

2. I have a utility class in the web application which tries to obtain
EntityManager as follows.

________________
public class CurrencyUtil {

    //@PersistenceContext(unitName="CurrencyRateUnit")
    private EntityManager em;

    private Collection currencies;


    public CurrencyUtil()
    {
        EntityManagerFactory emf =
Persistence.createEntityManagerFactory("CurrencyRateUnit");
        if(emf == null) System.out.println("emf is null!!!");
        em = emf.createEntityManager();
        if(em == null) System.out.println("em is null!!!");
    }
________________________________________

I have also tried with the above code in a servlet.

In all the cases I get the following error.

__________________________________________________________________________________________
18:02:36,328 ERROR [[Test]] Servlet.service() for servlet Test threw
exception
<openjpa-1.0.1-r420667:592145 fatal user error>
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
DataSource class name must be specified in the ConnectionDriverName
property.
    at
org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)
    at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:803)
    at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:568)
    at
org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1221)
    at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:476)
    at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:401)
    at
org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:102)
    at
org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:82)
    at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:861)
    at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:852)
    at
org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:630)
    at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:169)
    at
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
    at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
    at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
    at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
    at sample.jpa.currency.Test.doGet(Test.java:33)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at
org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
    at
org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
    at
org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at
org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:209)
    at
org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:347)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:803)
_______________________________________________________________________________________________

Looks like, JPA is not able to find persistence.xml and read the value of
"ConnectionDriverName" property.

I have also tried to use @PersistenceContext(unitName="CurrencyRateUnit")
annotation but failed. It throws the below exception

____________________
 javax.faces.FacesException: java.lang.InstantiationException: Some objects
to be injected were not found in jndi: [javax.naming.NotContextException:
sample.jpa.currency.CurrencyUtil/em]

_________________________

How do we get the proper EntityManager Instance in the web application??

Thanks in advance!!
Phani

Re: Trying to create EntityManager in web application

Posted by Phani Madgula <ph...@gmail.com>.
Thanks Jacek.


On 6/3/08, Jacek Laskowski <ja...@laskowski.net.pl> wrote:
> On Tue, Jun 3, 2008 at 11:52 AM, Phani Madgula
> <ph...@gmail.com> wrote:
>
>> I was able to inject EntityManager in a servlet class by placing
>> META-INF/persistence.xml in WEB-INF/classes. Only when
>> META-INF/peristence.xml is placed in WEB-INF/classes does the web
>> application is able to read the persistence.xml (application
>> classloader is able to find it).
>
> I couldn't figure it out myself either why META-INF in the webapp root
> was not searched for persistence.xml's, but that's how it's in webapps
> (I guess it's because the classloader for a webapp doesn't include /
> in its classpath). It'll change in Java EE 6 (I couldn't resist
> mentioning it ;-))
>
> Anyway, I think you'd be better off placing your entities (or better
> the classes that constitute the model) to a separate project and
> include jar file only. It makes your model "technology clean" and no
> ties with JPA will ever exist in the model. persistence.xml and
> orm.xml would go to WEB-INF/classes/META-INF or any other jar file in
> WEB-INF/lib. It could be that  the jar file with orm.xml and
> persistence.xml files would contain these files only so it's possible
> to replace just the jar file to change the jpa configuration.
>
> Just a couple of ideas.
>
> Jacek
>
> --
> Jacek Laskowski
> http://www.JacekLaskowski.pl
>

Re: Trying to create EntityManager in web application

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Tue, Jun 3, 2008 at 11:52 AM, Phani Madgula
<ph...@gmail.com> wrote:

> I was able to inject EntityManager in a servlet class by placing
> META-INF/persistence.xml in WEB-INF/classes. Only when
> META-INF/peristence.xml is placed in WEB-INF/classes does the web
> application is able to read the persistence.xml (application
> classloader is able to find it).

I couldn't figure it out myself either why META-INF in the webapp root
was not searched for persistence.xml's, but that's how it's in webapps
(I guess it's because the classloader for a webapp doesn't include /
in its classpath). It'll change in Java EE 6 (I couldn't resist
mentioning it ;-))

Anyway, I think you'd be better off placing your entities (or better
the classes that constitute the model) to a separate project and
include jar file only. It makes your model "technology clean" and no
ties with JPA will ever exist in the model. persistence.xml and
orm.xml would go to WEB-INF/classes/META-INF or any other jar file in
WEB-INF/lib. It could be that  the jar file with orm.xml and
persistence.xml files would contain these files only so it's possible
to replace just the jar file to change the jpa configuration.

Just a couple of ideas.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Trying to create EntityManager in web application

Posted by Phani Madgula <ph...@gmail.com>.
Hi,

I was able to inject EntityManager in a servlet class by placing
META-INF/persistence.xml in WEB-INF/classes. Only when
META-INF/peristence.xml is placed in WEB-INF/classes does the web
application is able to read the persistence.xml (application
classloader is able to find it).

I felt it's quite offbeat to have META-INF/persistence.xml in
WEB-INF/classes?? We usually have this META-INF folder at the root of
archive (as a sibling to WEB-INF folder). Would this be a right
option??

Thanks
Phani

On 5/29/08, Viet Nguyen <vh...@gmail.com> wrote:
> I figure that you would have an EJB app that defines some entity beans
> because you have a persistence.xml and you refer to this xml so that
> you can get a hold of some Entity Beans via the EntityManagerFactory.
>
> -Viet
>

Re: Trying to create EntityManager in web application

Posted by Viet Nguyen <vh...@gmail.com>.
I figure that you would have an EJB app that defines some entity beans
because you have a persistence.xml and you refer to this xml so that
you can get a hold of some Entity Beans via the EntityManagerFactory.

-Viet

Re: Trying to create EntityManager in web application

Posted by Phani Madgula <ph...@gmail.com>.
HI Viet,

I do not have EJB application. I am trying to use JPA in a WEB application.
I created META-INF folder at the root of the WEB application and placed
persistence.xml in the META-INF folder.

Am I missing something here?? Let me also try different options.

Thanks
Phani

On Wed, May 28, 2008 at 6:52 PM, Viet Nguyen <vh...@gmail.com> wrote:

> Hi,
>
> I will make comments inline...
>
> On Wed, May 28, 2008 at 8:37 AM, Phani Madgula
> <ph...@gmail.com> wrote:
> > Hi,
> >
> > I was trying to obtain javax.persistence.EntityManager in a web
> application
> > as follows.
> >
> > 1. Created persistence.xml in META-INF folder.
>
> Are you sure the persistence.xml is in the {ejb jar}/META-INF folder
> and not the another META-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"
> > version="1.0"
> >                 xsi:schemaLocation="
> http://java.sun.com/xml/ns/persistence
> > http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> >     <persistence-unit name="CurrencyRateUnit">
> >         <description>JPA JSF Sample</description>
> >
> >
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> >         <class>sample.jpa.currency.Currency</class>
> >         <properties>
> >             <property name="openjpa.ConnectionURL"
> > value="jdbc:derby:CurrencyDB" />
> >             <property name="openjpa.ConnectionDriverName"
> > value="org.apache.derby.jdbc.EmbeddedDriver" />
> >             <property name="ConnectionUserName" value="app" />
> >             <property name="openjpa.jdbc.SynchronizeMappings"
> value="false"
> > />
> >         </properties>
> >     </persistence-unit>
> > </persistence>
> >
> > ______________________________________________________________________
> >
> > 2. I have a utility class in the web application which tries to obtain
> > EntityManager as follows.
> >
> > ________________
> > public class CurrencyUtil {
> >
> >     //@PersistenceContext(unitName="CurrencyRateUnit")
> >     private EntityManager em;
>
> You can also try
>
> @PersistenceUnit(unitName="CurrencyRateUnit")
> private EntityManagerFactory emf;
>
> >
> >     private Collection currencies;
> >
> >
> >     public CurrencyUtil()
> >     {
> >         EntityManagerFactory emf =
> > Persistence.createEntityManagerFactory("CurrencyRateUnit");
> >         if(emf == null) System.out.println("emf is null!!!");
> >         em = emf.createEntityManager();
> >         if(em == null) System.out.println("em is null!!!");
> >     }
> > ________________________________________
> >
> > I have also tried with the above code in a servlet.
> >
> > In all the cases I get the following error.
> >
> >
> __________________________________________________________________________________________
> > 18:02:36,328 ERROR [[Test]] Servlet.service() for servlet Test threw
> > exception
> > <openjpa-1.0.1-r420667:592145 fatal user error>
> > org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
> > DataSource class name must be specified in the ConnectionDriverName
> > property.
> >     at
> >
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)
> >     at
> >
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:803)
> >     at
> >
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:568)
> >     at
> >
> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1221)
> >     at
> >
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:476)
> >     at
> >
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:401)
> >     at
> > org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:102)
> >     at
> > org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:82)
> >     at
> >
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:861)
> >     at
> >
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:852)
> >     at
> >
> org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:630)
> >     at
> >
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:169)
> >     at
> >
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
> >     at
> >
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
> >     at
> >
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
> >     at
> >
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
> >     at sample.jpa.currency.Test.doGet(Test.java:33)
> >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
> >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
> >     at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> >     at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> >     at
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
> >     at
> >
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
> >     at
> >
> org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
> >     at
> >
> org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
> >     at
> >
> org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
> >     at
> >
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> >     at
> >
> org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:209)
> >     at
> >
> org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:347)
> >     at
> >
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> >     at
> >
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> >     at
> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
> >     at
> >
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
> >     at
> >
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> >     at
> >
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
> >     at
> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> >     at java.lang.Thread.run(Thread.java:803)
> >
> _______________________________________________________________________________________________
> >
> > Looks like, JPA is not able to find persistence.xml and read the value of
> > "ConnectionDriverName" property.
> >
> > I have also tried to use @PersistenceContext(unitName="CurrencyRateUnit")
> > annotation but failed. It throws the below exception
> >
> > ____________________
> >  javax.faces.FacesException: java.lang.InstantiationException: Some
> objects
> > to be injected were not found in jndi: [javax.naming.NotContextException:
> > sample.jpa.currency.CurrencyUtil/em]
> >
> > _________________________
> >
> > How do we get the proper EntityManager Instance in the web application??
> >
> > Thanks in advance!!
> > Phani
> >
> >
>
> Thanks,
> Viet
>

Re: Trying to create EntityManager in web application

Posted by Viet Nguyen <vh...@gmail.com>.
Hi,

I will make comments inline...

On Wed, May 28, 2008 at 8:37 AM, Phani Madgula
<ph...@gmail.com> wrote:
> Hi,
>
> I was trying to obtain javax.persistence.EntityManager in a web application
> as follows.
>
> 1. Created persistence.xml in META-INF folder.

Are you sure the persistence.xml is in the {ejb jar}/META-INF folder
and not the another META-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"
> version="1.0"
>                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>     <persistence-unit name="CurrencyRateUnit">
>         <description>JPA JSF Sample</description>
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>         <class>sample.jpa.currency.Currency</class>
>         <properties>
>             <property name="openjpa.ConnectionURL"
> value="jdbc:derby:CurrencyDB" />
>             <property name="openjpa.ConnectionDriverName"
> value="org.apache.derby.jdbc.EmbeddedDriver" />
>             <property name="ConnectionUserName" value="app" />
>             <property name="openjpa.jdbc.SynchronizeMappings" value="false"
> />
>         </properties>
>     </persistence-unit>
> </persistence>
>
> ______________________________________________________________________
>
> 2. I have a utility class in the web application which tries to obtain
> EntityManager as follows.
>
> ________________
> public class CurrencyUtil {
>
>     //@PersistenceContext(unitName="CurrencyRateUnit")
>     private EntityManager em;

You can also try

@PersistenceUnit(unitName="CurrencyRateUnit")
private EntityManagerFactory emf;

>
>     private Collection currencies;
>
>
>     public CurrencyUtil()
>     {
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("CurrencyRateUnit");
>         if(emf == null) System.out.println("emf is null!!!");
>         em = emf.createEntityManager();
>         if(em == null) System.out.println("em is null!!!");
>     }
> ________________________________________
>
> I have also tried with the above code in a servlet.
>
> In all the cases I get the following error.
>
> __________________________________________________________________________________________
> 18:02:36,328 ERROR [[Test]] Servlet.service() for servlet Test threw
> exception
> <openjpa-1.0.1-r420667:592145 fatal user error>
> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
> DataSource class name must be specified in the ConnectionDriverName
> property.
>     at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)
>     at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:803)
>     at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:568)
>     at
> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1221)
>     at
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:476)
>     at
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:401)
>     at
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:102)
>     at
> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:82)
>     at
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:861)
>     at
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:852)
>     at
> org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:630)
>     at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:169)
>     at
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
>     at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
>     at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
>     at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
>     at sample.jpa.currency.Test.doGet(Test.java:33)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>     at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>     at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>     at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>     at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
>     at
> org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
>     at
> org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
>     at
> org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
>     at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>     at
> org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:209)
>     at
> org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:347)
>     at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>     at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>     at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
>     at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>     at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>     at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
>     at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>     at java.lang.Thread.run(Thread.java:803)
> _______________________________________________________________________________________________
>
> Looks like, JPA is not able to find persistence.xml and read the value of
> "ConnectionDriverName" property.
>
> I have also tried to use @PersistenceContext(unitName="CurrencyRateUnit")
> annotation but failed. It throws the below exception
>
> ____________________
>  javax.faces.FacesException: java.lang.InstantiationException: Some objects
> to be injected were not found in jndi: [javax.naming.NotContextException:
> sample.jpa.currency.CurrencyUtil/em]
>
> _________________________
>
> How do we get the proper EntityManager Instance in the web application??
>
> Thanks in advance!!
> Phani
>
>

Thanks,
Viet