测试时报错但测试可通常运作
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(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at net.sf.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
at net.sf.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:172)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:796)
at TestMain.main(TestMain.java:22)
在hibernate.cfg.xml中session-factory设立了name属性,hibernate会意欲把这个sessionfacotry登记到jndi中去
将name属性去掉即可解决
本文来源:
我的异常网
Java Exception
Dotnet Exception
Oracle Exception
- 3036 - com.ibatis.struts.BeanActionException
- 3037 - javax.servlet.jsp.JspException:Cannot find bean under name org.apache.struts.taglib.html.BEAN
- 3038 - org.hibernate.exception.GenericJDBCException: could not load an entity:
- 3039 - java异常机制
- 3040 - org.hibernate.SessionException: Session is closed!
- 3041 - java.lang.IllegalMonitorStateException
- 3042 - java.lang.UnsupportedClassVersionError: Bad version number in .class file
- 3043 - Error creating the view.An error occurred while automatically activating bundle org.eclipse.jdt.ui
- 3044 - 警告: Error setting value
- 3045 - org.hibernate.LazyInitializationException:could not initialize proxy