【发布时间】:2015-08-07 20:58:13
【问题描述】:
大家好,我一直在尝试将我的应用程序配置为使用 Hibernate ORM,但在 JNDI 属性规范方面遇到了挑战,因为我无法为 tomcat 指定“hibernate.jndi.class”,当我不断收到错误消息时应用程序尝试配置休眠 ("javax.naming.NoInitialContextException: 需要在环境或系统属性中指定类名,或作为小程序参数,或在应用程序资源文件中:java.naming.factory.initial")。
我想知道是否有人在 tomcat 上成功配置了 JNDI,如果是,我希望这些人共享 hibernate.cfg.xml 文件。下面我发布了我当前的 hibernate.cfg.xml 文件。
提前致谢。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="HibernateSessionFactory">
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/TestDB</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">inheritance</property>
<!-- Mapping with model class containing annotations -->
<mapping resource="user.hbm.xml"/>
</session-factory>
</hibernate-configuration>
【问题讨论】:
标签: hibernate tomcat hibernate-mapping