标签:
WARN: HHH000277: Could not bind factory to JNDI
org.hibernate.engine.jndi.JndiException: Error parsing JNDI name [foo]
at org.hibernate.engine.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:141)
at org.hibernate.engine.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:157)
at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:103)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:497)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930)
at com.taray.view.TestMain.main(TestMain.java:24)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.getNameParser(InitialContext.java:480)
at org.hibernate.engine.jndi.internal.JndiServiceImpl.parseName(JndiServiceImpl.java:135)
... 6 more
一个警告,错误原因hibernate.cfg.xml下面<session-factory name="foo">要去掉name属性:
<?xml version=‘1.0‘ encoding=‘utf-8‘?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="foo"> <!-- hibernate设计者给了我们常用的配置,其实要改数据库就改这儿就好了! --> <!-- property中的connection.*必须是点出来的,否则报错 --> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="connection.username">SCOTT</property> <property name="connection.password">Admin</property> <property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:orcl</property> <!-- 配置dialect方言 明确告诉hibernate我现在连接的哪个数据库 --> <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property> <mapping resource="com/taray/domain/Users.hbm.xml"/> </session-factory> </hibernate-configuration>
WARN: HHH000277: Could not bind factory to JNDI
标签:
原文地址:http://www.cnblogs.com/taray/p/5887247.html