Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA CreateEntityManagerFactory() method hangs

I am using this method in the following way

EntityManagerFactory emftemp = Persistence.createEntityManagerFactory("XYZ");

and my persistence.xml has the following entry for this unit

<persistence-unit name="XYZ" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.show_sql" value="false"/>
        <property name="hibernate.hbm2ddl.auto" value="validate"/>
        <property name="hibernate.query.substitutions" value="true=1, false=0"/>
        <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="hibernate.connection.url" value="jdbc:oracle:thin:@aesop-db.corp.nlg1.com:1521:TLCSDEV4"/>
        <property name="hibernate.connection.username" value="abcd"/>
        <property name="hibernate.connection.password" value="abcd"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/>
    <property name="hibernate.connection.timeout" value="120"/>
    <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
    <property name="hibernate.c3p0.min_size" value="2"/>
    <property name="hibernate.c3p0.max_size" value="2"/>
    <property name="hibernate.c3p0.idle_test_period" value="60"/>
    </properties>
</persistence-unit>

This is a Java application and I am using the hibernate3.jar and I am using ejb3-persistence.jar and JDK1.5.

The problem is that everytime I run the application, it hangs on this call . Its not throwing any exception or error . It just hangs at that point.

Can anyone help in identifying why it does not move forward ?

like image 803
TYS Avatar asked Mar 18 '26 08:03

TYS


1 Answers

Two thoughts:

  1. When something hangs it's often IO/networking issues to blame. So, try to make sure that the DB is really alive, and that you can connect to it from your computer.
  2. This could be a duplicate of Persistence.createEntityManagerFactory takes ages
like image 94
Oleg Mikheev Avatar answered Mar 19 '26 21:03

Oleg Mikheev