Questo contenuto non è disponibile nella lingua selezionata.
3.8.4. JMX deployment
The line
cfg.buildSessionFactory()
still has to be executed somewhere to get a SessionFactory
into JNDI. You can do this either in a static
initializer block, like the one in HibernateUtil
, or you can deploy Hibernate as a managed service.
Hibernate is distributed with
org.hibernate.jmx.HibernateService
for deployment on an application server with JMX capabilities, such as JBoss Enterprise Application Platform. The actual deployment and configuration is vendor-specific. Here is an example jboss-service.xml
for JBoss 4.0.x:
This file is deployed in a directory called
META-INF
and packaged in a JAR file with the extension .sar
(service archive). You also need to package Hibernate, its required third-party libraries, your compiled persistent classes, as well as your mapping files in the same archive. Your enterprise beans (usually session beans) can be kept in their own JAR file, but you can include this EJB JAR file in the main service archive to get a single (hot-)deployable unit.