hi everyone.
I have a little problem with binding Hibernate SessionFactory to JNDI.
I'm always getting that messages in Log, when i'm deploying my web-app on jBoss server (5.1).
Code:
00:25:22,049 INFO [SettingsFactory] Named query checking : enabled
00:25:22,150 INFO [SessionFactoryImpl] building session factory
[b]00:25:22,154 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured[/b]
00:25:22,185 INFO [SchemaUpdate] Running hbm2ddl schema update
00:25:22,186 INFO [SchemaUpdate] fetching database metadata
hibernate.cfg.xml
Code:
<hibernate-configuration>
<session-factory name="java:comp:/hibernateSessionFactory">
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/seam</property>
<property name="hibernate.connection.username">surly</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.default_entity_mode">pojo</property>
<property name="hibernate.session_factory_name">java:comp:/hibernateSessionFactory</property>
<property name="hibernate.connection.datasource">seam_testDatasource</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.auto_close_session">false</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<!-- <mapping class="myentity" package="org.domain.seamtest.session"/> -->
</session-factory>
persistance.xml
Code:
<persistence-unit name="seam_test" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/seam_testDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="jboss.entity.manager.factory.jndi.name" value="myfactory"/>
</properties>
</persistence-unit>
components.xml
Code:
....
<persistence:hibernate-session-factory auto-create="true"
cfg-resource-name="hibernate.cfg.xml" name="hibernateSessionFactory"/>
<persistence:managed-hibernate-session auto-create="true"
name="hibernateSession" session-factory-jndi-name="hibernateSessionFactory"/>
....
mysession.java, base class DAO.java, local interface
Code:
public class DAO {
protected DAO() {
}
//some methods
private static final Logger log = Logger.getAnonymousLogger();
//HERE IS IT!!
@In
public Session hibernateSession;
}
@Stateless
@Name("mysession")
public class mysession extends DAO implements mysessionLocal {
@PostConstruct
public void init() {
System.out.println("INIT mysession bean");
}
//some methods
}
@Local
public interface mysessionLocal {
//methods
}
I write simple web-application using SEAM framework, and i decided to use Hibernate instead JPA in my stateless EJB.
I want to INJECT (@In) Hibernate Session in every created EJB.Tell me, what is wrong here, why i cant to inject Session to EJB?
i'm always getting this, when my EJB constructed:
Code:
00:31:10,091 ERROR [TxPolicy] javax.ejb.EJBTransactionRolledbackException: SessionFactory not found in JNDI: hibernateSessionFactory