javax.naming.NoInitialContextException: Need to specify class name in environment or system property
来源:互联网 发布:阿里云 备案服务号 编辑:程序博客网 时间:2024/05/16 09:01
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
在使用hibernate 3.5.1的时候 报错,原因是 hibernate 配置文件中给sessionFactory 配置了name属性,把这个属性删掉,否则会去找jndi,但是运行环境中没有使用jndi所以会报这个错。
<hibernate-configuration> <session-factory name=""> <property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name="connection.url">jdbc:sqlserver:URL###</property> <property name="dialect">org.hibernate.dialect.SQLServerDialect</property> <property name="connection.username">NAME</property> <property name="connection.password">PASS</property> <property name="hibernate.default_schema">dbo</property> <mapping class="za.co.epsilon.domain.OverrideItemDo" /> <mapping class="za.co.epsilon.domain.BatchOverrideDo" /> <mapping class="za.co.epsilon.domain.TaskOverrideDo" /> </session-factory></hibernate-configuration>
You need to remove the name attribute from your opening session factory tag in your hibernate configuration file so that it looks like the following:
<session-factory> 不要再里面加属性<session-factory name=""> 否则会报错
public static SessionFactory getSessionFactory() { String sfName = configuration.getProperty(Environment.SESSION_FACTORY_NAME); if ( sfName != null && !sfName.equals("")) { log.debug("Looking up SessionFactory in JNDI"); try { return (SessionFactory) new InitialContext().lookup(sfName); } catch (NamingException ex) { throw new RuntimeException(ex); } } else if (sessionFactory == null) { sessionFactory = new Configuration().configure().buildSessionFactory(); } return sessionFactory; }
- 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
- 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,
- javax.naming.NoInitialContextException: Need to specify class name in XXX解决
- WLS Exception: Need to specify class name in environment or system property Solution
- EJB3.0异常总结--- Need to specify class name in environment or system property,
- Need to specify class name in environment or system property, or as an applet parameter, or in an ap
- Need to specify class name in environment or system property, or as an applet parameter, or in an ap
- Need to specify class name in environment or system property, or as an applet parameter, or in a
- WEBSPHERE连接数据库测试错误Need to specify class name in environment or system property, or as an applet parameter, or in an application
- Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: j
- 在使用jetty配置jndi的时候报错“Need to specify class name in environment or system property, or as an applet pa
- javax.naming.NoInitialContextException解决
- javax.naming.NoInitialContextException
- javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory
- javax.naming.NoInitialContextException之Hibernate
- JS判断是IPONE还是IPAD
- 安装iis合集(xp,2003,win7,win2008)
- 使用 Date、DateFormat
- Device Mapper Multipath(DM-Multipath)
- Postgresql数据库压力测试下真的会逐渐变慢吗?
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property
- 简单js正则表达式
- ACM HDOJ 下沙的沙子有几粒?
- variable for statis
- 'WTF Mobile Web':发掘糟糕的移动Web设计
- 【Django tutorial 5】
- Linux查找命令大全
- JavaScript框架设计
- ReadWriteWeb评出2011十大Web产品:Chrome、Evernote、Siri上榜