Pages

Saturday, February 25, 2012

Exception: Could not bind factory to JNDI


WARN: HHH000277: Could not bind factory to JNDI
org.hibernate.service.jndi.JndiException: Error parsing JNDI name []
at org.hibernate.service.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:92)
at org.hibernate.service.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:108)
at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:89)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:464)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)
at com.GamersCom.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:21)
at com.GamersCom.util.HibernateUtil.<clinit>(HibernateUtil.java:15)
at com.GamersCom.dao.UserDAO.listUser(UserDAO.java:22)
at com.GamersCom.app.main.main(main.java:20)


Hibernate.cfg.xml
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/gamers</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.default_schema">gamers</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<mapping resource="com/GamersCom/domain/User.hbm.xml" />
</session-factory>
</hibernate-configuration>

SOLUTION:
     remove "name" attribute from session-Factory. It is not required unless you want to bind SessionFactory to JNDI.



1 comment: