javax.naming.NoInitialContextException: Need to specify class name in environment or system property
2011-12-07 17:54
513 查看
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所以会报这个错。
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=""> 否则会报错
在使用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, or as an applet parameter,
- 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 XXX解决
- Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.init
- WLS Exception: Need to specify class name in environment or system property Solution
- WLS Exception: Need to specify class name in environment or system property Solution
- Need to specify class name in environment or system property, or as an applet parameter, or in an ap
- 在使用jetty配置jndi的时候报错“Need to specify class name in environment or system property, or as an applet pa
- Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: j
- Need to specify class name in environment or system property, or as an applet parameter, or in a
- Need to specify class name in environment or system property, or as an applet parameter, or in an ap
- EJB3.0异常总结--- Need to specify class name in environment or system property,
- javax.naming.NameNotFoundException: Name [jdbc/lappJDBC] is not bound in this Context. Unable to fi
- 关于使用EJB时出现javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory的问题
- javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory
- javax.naming.NamingException: No naming context bound to this class loader