Hibernate出现javax.naming.NoInitialContextException 错误的解决办法
2018-01-13 19:32
555 查看
异常信息:
很奇怪我的项目并没有使用到JNDI,但是却抛出JNDI相关的异常信息。
原来是Hibernate的配置文件hibernate.cfg.xml有问题
原因:
session-factory
元素多了属性 name.
这样,hibernate会试图把这个sessionfacotry注册到JNDI中去
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=""> <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>
原因:
session-factory
元素多了属性 name.
这样,hibernate会试图把这个sessionfacotry注册到JNDI中去
相关文章推荐
- Hibernate出现javax.naming.NoInitialContextException 错误的解决办法
- Hibernate出现javax.naming.NoInitialContextException 错误的解决办法
- [转载]Hibernate出现javax.naming.NoInitialContextException 错误的解决办法
- Hibernate出现javax.naming.NoInitialContextException 错误的解决办法
- javax.naming.NoInitialContextException hibernate错误的解决方法
- javax.naming.NoInitialContextException 错误的解决办法
- 关于使用EJB时出现javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory的问题
- javax.naming.NoInitialContextException: Need to specify class name in XXX解决
- javax.naming.NoInitialContextException解决
- javax.naming.NoInitialContextException解决
- javax.naming.NoInitialContextException错误的解决方案
- 关于ejb中异常javax.naming.NoInitialContextException的处理办法
- javax.naming.NoInitialContextException之Hibernate
- javax.naming.NoInitialContextException错误的解决方案
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- 根据错误原理解决Hibernate运行出现No CurrentSessionContext configured!错误
- Could not find class 'javax.naming.directory.InitialDirContext'的解决办法!
- axis2 1.5.5 + Websphere 8.0 ,FileUploadException 与 NoInitialContextException 的解决办法
- javax.naming.NoInitialContextException
- 启动Tomcat时出现javax.naming.NameNotFoundException: Name xxx is not bound in this Context情况解决方式