openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject Re: Possible reasons for Persistence.createEntityManagerFactory returning null
Date Wed, 13 Aug 2008 14:21:25 GMT
KK,
As you have already surmised, the most common reason for returning null is
when the requested EMF can't be found using your classpath and packaging.
You don't mention this, but I'm assuming your createEMF invocation is like
this (based on your persistence.xml):

Persistence.createEntityManagerFactory("ibm");

The other possibility is that you don't have openjpa properly "installed".
If the JPA Persistence class can't find the provider that you mentioned in
your persistence.xml, then you might get a null returned.  (I can't remember
exactly how the Persistence class processes this case.)

You might want to try turning on TRACE for openjpa and see if we are getting
involved in the processing at all.  If we are, then this might help explain
why the EMF couldn't be created.

The JPA spec outlines the requirements for the location of the
persistence.xml file.  It's very explicit for the EE packaging
requirements.  For the SE environment, it just states that the
META-INF/persistence.xml must be found at the root of the persistence unit.

Hope this information helps.
Kevin
On Wed, Aug 13, 2008 at 4:07 AM, KK <kamlesh_kumar@persistent.co.in> wrote:

>
> Hi,
> I am creating a stand alone java program with OpenJPA. I have placed my
> persistence.xml in bin\META-INF\. But when I do
> Persistence.createEntityManagerFactory, it is returning null. When I used
> the same folder structure with Toplink JPA, it is working fine.
>
> The method is just returning null and there is no exception which can
> indicate the possible reasons. Please tell me what can be the possible
> reasons for the Persistence.createEntityManagerFactory("persistence-unit
> name") method to return null.
>
> Regards,
> KK
>
> My persistence.xml is as given below:
>
> <?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">
>        <persistence-unit name="ibm" transaction-type="RESOURCE_LOCAL">
>                <provider>
>
>  org.apache.openjpa.persistence.PersistenceProviderImpl
>                </provider>
>                <mapping-file>mapping/orm.xml</mapping-file>
>                <class>com.entity.Customer</class>
>                <class>com.entity.Organization</class>
>                <class>com.BillingAddress</class>
>                <properties>
>                        <property name="openjpa.Log"
>                                value="DefaultLevel=WARN, Tool=INFO" />
>                        <property name="openjpa.ConnectionURL"
>                                value="jdbc:mysql://localhost:3306/wdp_jpa"
> />
>                        <property name="openjpa.ConnectionUserName"
> value="root" />
>                        <property name="openjpa.ConnectionDriverName"
>                                value="com.mysql.jdbc.Driver" />
>                        <property name="openjpa.ConnectionPassword"
> value="admin" />
>                        <property name="openjpa.jdbc.SynchronizeMappings"
>
>  value="buildSchema(SchemaAction=add,deleteTableContents)" />
>                </properties>
>
>        </persistence-unit>
> </persistence>
>
> --
> View this message in context:
> http://n2.nabble.com/Possible-reasons-for-Persistence.createEntityManagerFactory-returning-null-tp721529p721529.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message