Hello all,
I have gotten Hibernate Annotations and the EntityManager working in my J2SE 5 environment w/o issue. I create a JAR file with all of the hibernate annotated classes and have a persistence.xml file in the META-INF directory of the my JAR file with all the hibernate properties.
This setup works fine in J2SE. However, when running as a web application in Tomcat, I get the following error:
INFO: Not binding factory to JNDI, no JNDI name configured
I have all the required libraries in the WEB-INF/lib directory of my war file. Does anyone know what could be the issue? I got this error before when there was a configuration error. However, the same persistence.xml works fine in the J2SE enviroment so I don't know what could be the issue here. Any help would be greatly appreciated.
Code:
@PersistenceUnit private static EntityManagerFactory mFactory = null;
public static EntityManagerFactory getEntityManagerFactory() {
if (mFactory == null) {
mFactory = Persistence.createEntityManagerFactory("f1");
}
return mFactory;
}
PERSISTENCE.XML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="f1">
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/f1"/>
<property name="hibernate.max_fetch_depth" value="3"/>
</properties>
</persistence-unit>
</persistence>