No transaction around seam hibernate-managed session
malcomtom Jul 14, 2013 3:22 AMdear community,
I am using Jboss 4.2.3 with seam 2.2 and most of it works ok. My problem is,
that i have to do manually transaction management (e.g.) currentSession.beginTransaction() ....
although i thought, that ive configered everything for a managed transaction
I thought that ive to add "@Transactional", but this causes jboss to return a 403 Error (no further loggin on console/log)
----------- called democode ---------
@Transactional
public void saveorupdate(Person updatedPerson) {
try {
// currentSession.getTransaction().isActive() -> returns false!
currentSession.saveOrUpdate(updatedPerson);
currentSession.flush();
} catch (HibernateException e) {
System.out.println("error! "+e);
e.printStackTrace();
}
// updatedPerson is not persisted, because of missing transaction
}
-----------------------------------------------
--------------- components.xml ----------
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:drools="http://jboss.com/products/seam/drools"
xmlns:bpm="http://jboss.com/products/seam/bpm"
xmlns:security="http://jboss.com/products/seam/security"
xmlns:mail="http://jboss.com/products/seam/mail"
xmlns:web="http://jboss.com/products/seam/web"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.2.xsd
http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.2.xsd">
<core:init debug="true" jndi-pattern="@jndiPattern@"/>
<core:manager concurrent-request-timeout="500"
conversation-timeout="120000"
conversation-id-parameter="cid"
parent-conversation-id-parameter="pid"/>
<!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
<web:hot-deploy-filter url-pattern="*.seam"/>
<transaction:hibernate-transaction session="persistenceSession"/>
<persistence:managed-hibernate-session
name="currentSession" auto-create="true"
session-factory="#{hibernateSessionFactory.getSessionFactory(0)}" />
<!-- <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>-->
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}"/>
</event>
<event type="org.jboss.seam.security.loginSuccessful">
<action execute="#{redirect.returnToCapturedView}"/>
</event>
</components>
---------------------------------------------------
---------- hibernate.cfg.xml --------------
<hibernate-configuration>
<session-factory name="java:/testSeamHibernateSessionFactory">
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/playgdb</property>
<property name="hibernate.connection.username">test</property>
<property name="hibernate.connection.password">test</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<!-- Hibernate sEARCH configuration </property>-->
<property name="hibernate.search.autoregister_listeners">true</property>
<property name="hibernate.search.worker.execution">async</property>
<property name="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</property>
<property name="hibernate.search.default.indexBase">C:\Temp\hibernate_search_index</property>
<property name="hibernate.search.default.exclusive_index_use">true</property>
<property name="hibernate.search.default.optimizer.transaction_limit.max">100</property>
<property name="hibernate.search.worker.thread_pool.size">2</property>
<property name="hibernate.search.worker.buffer_queue.max">50</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">1000</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="show_sql">false</property>
<property name="hibernate.format_sql">false</property>
<property name="hibernate.cache.use_structured_entries">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory</property>
<property name="net.sf.ehcache.configurationResourceName">/ehcache.xml</property>
<property name="hibernate.generate_statistics">true</property>
<property name="transaction.flush_before_completion">true</property>
<!-- <property name="hibernate.hbm2ddl.auto">create-drop</property>-->
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.id.new_generator_mappings">true</property>
<property name="hibernate.ejb.interceptor">consearch.util.CsObjectInterceptor</property>
<mapping class="com.domain.Person" />
</session-factory>
</hibernate-configuration>
---------------------------------------------------
Thanking you very much for helping me
best regards
malcom