Hibernate出现javax.naming.NoInitialContextException 错误的解决办法
异常信息:
08:02:56,329 WARN SessionFactoryObjectFactory:123 - Could not unbind factory from JNDI
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.unbind(InitialContext.java:416)
at org.hibernate.impl.SessionFactoryObjectFactory.removeInstance(SessionFactoryObjectFactory.java:116)
at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:806)
at org.hibernate.test.junit.UserTest.tearDown(UserTest.java:43)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
很奇怪我的项目并没有使用到JNDI,但是却抛出JNDI相关的异常信息。
原来是Hibernate的配置文件hibernate.cfg.xml有问题
<hibernate-configuration>
<session-factory name="foo">
<property name="hibernate.connection.url">jdbc:oracle:thin:@10.240.144.25:1521:MES</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username">*****</property>
<property name="hibernate.connection.password">*****</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property> <mapping resource="org/hibernate/test/User.hbm.xml"/> </session-factory>
</hibernate-configuration>
原因:<seesion-factory>元素多了属性 name.
Hibernate出现javax.naming.NoInitialContextException 错误的解决办法的更多相关文章
- javax.naming.NoInitialContextException错误的解决方案
今天,学习用了一下nutz框架,写了一个HelloWorld的小程序,在用jndi配置数据源时,写了一个测试类,并在main方法中调用了jndi获得数据库连接,但是报错了,错误信息如下: javax. ...
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
javax.naming.NoInitialContextException: Need to specify class name in environment or system property ...
- 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
小弟初次用JNDI,使用数据源连接数据库,配置完相关的xml文件后,激动的我赶紧测试了一下,结果悲剧了,报出了错误: javax.naming.NoInitialContextException:Ne ...
- Oracle的常见错误及解决办法
ORA-12528: TNS:listener: all appropriate instances are blocking new connections ORA-12528问题是因为监听中的服务 ...
- WIN7下安装visualC++2008 redistributable 出现1935错误的解决办法(转自)
转自:http://zhidao.baidu.com/link?url=jylNh_JeANi4wrOMmd4d2i06e_N3QCw7z6BLGiNNNTu1Hc6ADTkUq2PORExKmjtk ...
- Oracle客户端工具出现“Cannot access NLS data files or invalid environment specified”错误的解决办法
Oracle客户端工具出现"Cannot access NLS data files or invalid environment specified"错误的解决办法 方法一:参考 ...
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" ...
- VS2010出现FileTracker : error FTK1011编译错误的解决办法
VS2010出现FileTracker : error FTK1011不知道是不是vs2010的一个bug,反正有人提交了. FileTracker : error FTK1011编译错误的解决办法有 ...
- SQL SERVER数据库备份时出现“操作系统错误5(拒绝访问)。BACKUP DATABASE 正在异常终止。”错误的解决办法
一般备份文件选择的目录为磁盘根目录或备份所选分区未授予sqlserver用户读写权限时会出现此错误. 解决办法就是给sqlserver用户授予权限: 选择要备份的文件夹 ,右键-->属性--&g ...
随机推荐
- 【翻译】配置RSVP-signaled LSP
源地址: https://www.juniper.net/techpubs/software/junos-security/junos-security10.2/junos-security-swco ...
- yii url美化 urlManager组件
yii的官方文档对此的解释如下: urlSuffix 此规则使用的url后缀,默认使用CurlManger::urlSuffix,值为null.例如可以将此设置为.html,让url看起来“像”是一 ...
- OC知识梳理-NSArray与NSMutableArray相关知识
知识普及: 1.数组中的元素在系统中都会有其默认对应的下标,下标是一个整形的数字,默认从0开始. 例:NSArray *arr3 = @["345","234" ...
- oc语言常用的字符串函数
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { ...
- setSupportActionBar(toolbar)导致程序崩溃闪退
最近在做一个项目,使用了第三方的开源项目,主要是想实现android5.0之后推出的MaterialDesign的风格,但是代码已经写好了,发现一运行就闪退,所以就开始debug,发现问题出现在 To ...
- 关于IOS多线程的好的技术博客
点击图片就能跳转链接到目标网页. 1.GCD<本人已阅,写的非常好>
- linux+jre+apache+mysql+tomcat调优
一.不再为Apache进程淤积.耗尽内存而困扰 0. /etc/my.cnf,在mysqld那一段加上如下一行: log-slow-queries=queries-slow.log 重启MySQL 酌 ...
- 使用Apache Tomcat Maven插件部署运行 Web 项目
什么是Apache Tomcat Maven Plugin? Maven Plugin 是Apache Tomcat 提供的一个Maven插件,它可以在你没有tomcat容器时将任何一个war项目文件 ...
- android 网络编程之HttpURLConnection与HttpClient使用与封装
1.写在前面 大部分andriod应用需要与服务器进行数据交互,HTTP.FTP.SMTP或者是直接基于SOCKET编程都可以进行数据交互,但是HTTP必然是使用最广泛的协议. 本文并 ...
- POI教程之第二讲:创建一个时间格式的单元格,处理不同内容格式的单元格,遍历工作簿的行和列并获取单元格内容,文本提取
第二讲 1.创建一个时间格式的单元格 Workbook wb=new HSSFWorkbook(); // 定义一个新的工作簿 Sheet sheet=wb.createSheet("第一个 ...