jboss4下的hibernate配置问题

05-04-06 4bug
在JBoss的文档里,有这个配置:
<mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">java:/DefaultDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.HSQLDialect</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>

<attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
</mbean>

其中DatasourceName的Jndi Name我知道在mysql-ds.xml(用的是Mysql)里在配置,但是SessionFactoryName的Jndi Name在哪配置呢?运行的时候总是说java:/hibernate/SessionFactory没找到。

4bug
2005-04-06 12:14
不好意思,第一次发贴,没注意到问题,重发一次。。

在JBoss的文档里,有这个配置:


其中DatasourceName的Jndi Name我知道在mysql-ds.xml(用的是Mysql)里在配置,但是SessionFactoryName的Jndi Name在哪配置呢?运行的时候总是说java:/hibernate/SessionFactory没找到。

xujun
2005-04-06 16:54
一个J2EE应用服务应该是一个ear文件。
你在jboss下的ear文件夹下建立一个har(例如test.har)文件夹,har下有个META-INF文件夹。下面放上一个hibernate-service.xml文件。
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">
java:/MySqlDS
</attribute>
<attribute name="Dialect">
net.sf.hibernate.dialect.MySQLDialect
</attribute>
<attribute name="SessionFactoryName">
java:/hibernate/SessionFactory
</attribute>
<attribute name="CacheProviderClass"> net.sf.hibernate.cache.HashtableCacheProvider
</attribute>
<!-- <attribute name="Hbm2ddlAuto">create-drop</attribute> -->
</mbean>
</server>

同时在ear文件夹下的META-INF中建立一个JBOSS-APP.XML文件
<?xml version="1.0" encoding="UTF-8"?>
<jboss-app>
<module>
<har>test.har</har>
</module>
</jboss-app>

就OK了