Realmente tá estrnaho Paulo.
Criei o arquivo .har com a seguinte estrutura
META-INF/hibernate-service.xml
META-INF/MANIFEST.MF
hibernate.properties
classes pojo
classes pojo/hibernateMapping.hbm.xml
O hibernate-service.xml tá assim:
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.har:service=Hibernate">
<attribute name="Datasource">java: DBSQLServerDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.SQLServerDialect</attribute>
<attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="MapResources">classes pojo/hibernateMapping.hbm.xml</attribute>
<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>
<attribute name="ShowSql">true</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>
</server>
O hibernate.properties tá assim:
hibernate.connection.username usuario
hibernate.connection.password senha
hibernate.connection.url jdbc:microsoft:sqlserver://ip da base:1433;SelectMethod=cursor;DatabaseName=nome da base
hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver
hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect
hibernate.show_sql true
Na classe HibernateUtil tento criar o Session da seguinte forma:
private static final String HIBERNATE_FACTORY_JDNI = "java:/hibernate/SessionFactory";
public static Session currentSession() throws NamingException, Exception {
SessionFactory factory = null;
try {
InitialContext ic = new InitialContext();
factory = (SessionFactory) ic.lookup(HIBERNATE_FACTORY_JDNI);
} catch (NamingException e) {
throw new NamingException("Hibernate session factory não encontrada em " + HIBERNATE_FACTORY_JDNI);
} catch (Exception e) {
throw new Exception("Hibernate session factory não encontrada em " + HIBERNATE_FACTORY_JDNI);
}
Session hSession = factory.openSession();
if (hSession == null) {
throw new Exception("Hibernate session factory lookup feito com sucesso, mas sessão corrente é nula");
}
return hSession;
}
Será que estou fazendo algo de errado ou está faltando algo?
Obrigado pela atenção.