码迷,mamicode.com
首页 > 其他好文 > 详细

WARN: HHH000277: Could not bind factory to JNDI

时间:2016-09-20 01:37:49      阅读:386      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!