Announcement Announcement Module
No announcement yet.
declarative transactions config Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • declarative transactions config

    I'm trying to setup declatative transaction management in Spring and I'm kind of stuck with the configuration.
    The spring itself doesn't give any error messages, but transactions doesn't seem to work at all.

    Here is my config :
    Oracle 10g
    Spring 2.0m3
    Tomcat 5.5.15
    Jdk 1.5
    Tapestry 4.0

    My ApplicationContext.xml :


    <bean id="created" class="ts.CreatedBean" singleton="false" dependency-check="all"/>

    <bean id="ts_global" class="ts.ts_global" singleton="true" dependency-check="all"/>

    <bean id="beanDS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" singleton="true" dependency-check="none" >
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="jdbc:oracle:thin:@" />
    <property name="username" value="TORGI" />
    <property name="password" value="TORGI" />
    <property name="validationQuery" value="SELECT 1 FROM dual" />
    <property name="maxActive" value="20" />
    <property name="maxIdle" value="10" />
    <property name="maxWait" value="-1" />
    <property name="removeAbandoned" value = "true" />
    <property name="removeAbandonedTimeout" value = "60" />
    <property name="testWhileIdle" value = "true" />
    <property name="initialSize" value = "1" />
    <property name="minIdle" value = "1" />
    <property name="timeBetweenEvictionRunsMillis" value = "30000" />
    <property name="numTestsPerEvictionRun" value = "3" />
    <property name="minEvictableIdleTimeMillis" value = "24000" />
    <property name="poolPreparedStatements" value="true" />
    <property name="maxOpenPreparedStatements" value="100" />
    <property name="accessToUnderlyingConnectionAllowed" value="false"/>
    <property name="defaultAutoCommit" value="false"/>
    <property name="defaultCatalog" value=""/>
    <property name="defaultReadOnly" value="false" />

    <!-- this is just my wrapper for jdbcTemplate-->
    <bean id="beanOracle" class="ts.ts_oracle" singleton="true" dependency-check="all" >
    <property name="DS"><ref bean="beanDS"/></property>

    <bean id="targetAction" class="ts.ts_action" singleton="true" dependency-check="none" >
    <property name="sql"><ref bean="beanOracle"/></property>

    <bean id="beanModel" class="ts.ts_model" singleton="false" dependency-check="none" >
    <property name="action"><ref bean="beanAction"/></property>

    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ref="beanDS"/>

    <bean id="beanAction" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager" ref="txManager"/>
    <property name="target" ref="targetAction"/>
    <property name="transactionAttributes">
    <prop key="*">PROPAGATION_REQUIRED,-RollbackException</prop>
    <prop key="update*">PROPAGATION_REQUIRED</prop>
    <prop key="x*">PROPAGATION_REQUIRED,readOnly</prop>


    Then in my *.java I do following :

    ts_action a = ( ts_action ) getTsGlobal().getApplicationContext().getBean( "beanAction" );
    a.doDelDemand( 10 );

    As far as I understand this should cause the transaction proxy to do its work, and I *know* that I do indeed call proxy , since if I generate an exception the stack trace shows :

    ts.ts_action$$FastClassByCGLIB$$6a367f47.invoke(<g enerated>)
    net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy. java:149)
    org.springframework.aop.framework.Cglib2AopProxy$C glibMethodInvocation.invokeJoinpoint(Cglib2AopProx
    org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :148)
    org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:100)
    org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :170)
    org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:643)
    ts.ts_action$$EnhancerByCGLIB$$2beee9c6.doDelDeman d(<generated>)
    ... More....

    But there is no commits or rollbacks issued to the oracle and there is no any trasaction log messages in the console .

    My log4j.xml :

    <category name="org.springframework.transaction">
    <priority value="DEBUG"/>
    <appender-ref ref="ASYNC"/>

    Tomcat console log :
    15:34:51.656 INFO [[/forms]] Loading Spring root WebApplicationContext
    15:34:51.703 INFO [CollectionFactory] JDK 1.4+ collections available
    15:34:51.718 INFO [CollectionFactory] Commons Collections 3.x available
    15:34:51.765 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    15:34:51.906 INFO [XmlWebApplicationContext] Bean factory for application context [Root WebApplicationContext]: istableBeanFactory defining beans [created,ts_global,beanDS,beanOracle,targetAction,b eanModel,txManager,beanAction];
    root of BeanFactory hierarchy
    15:34:51.921 INFO [XmlWebApplicationContext] 8 beans defined in application context [Root WebApplicationContext]
    15:34:51.921 INFO [XmlWebApplicationContext] Unable to locate MessageSource with name 'messageSource': using default [ ageSource@bdb375]
    15:34:51.921 INFO [XmlWebApplicationContext] Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@63e563]
    15:34:51.937 INFO [UiApplicationContextUtils] Unable to locate ThemeSource with name 'themeSource': using default [ dleThemeSource@d78df0]
    15:34:51.937 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in factory [ istableBeanFactory defining beans [created,ts_global,beanDS,beanOracle,targetAction,b eanModel,txManager,beanAction]; root of BeanFactory hier
    15:34:52.125 INFO [DefaultAopProxyFactory] CGLIB2 available: proxyTargetClass feature enabled
    15:34:52.406 INFO [ContextLoader] Using context class [ icationContext] for root WebApplicationContext
    15:34:52.406 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 750 ms
    15:34:54.500 INFO [ApplicationServlet] Initialized application servlet 'forms': 1а094 millis to create HiveMind Registry, 2а079 millis overall.
    15:34:55.031 WARN [SecurityCollection] Suspicious url pattern: "/html/*" - see section 11.2
    15:34:55.328 WARN [SecurityCollection] Suspicious url pattern: "/jmxproxy/*" - see section 11.2
    15:34:55.328 WARN [SecurityCollection] Suspicious url pattern: "/html/*" - see section 11.2
    15:34:55.328 WARN [SecurityCollection] Suspicious url pattern: "/status/*" - see section 11.2
    15:34:55.515 INFO [[/balancer]] org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRul e: Target string: News / Redirect URL:], [org.apache.webapp.balancer.rules.R
    equestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL:], [org.apache.webapp.balancer.rules.AcceptEverythingR ule: Redirect URL:]]
    15:34:55.890 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-8080
    15:34:56.187 INFO [ChannelSocket] JK: ajp13 listening on /
    15:34:56.218 INFO [JkMain] Jk running ID=0 time=0/32 config=null
    15:34:56.281 INFO [StoreLoader] Find registry server-registry.xml at classpath resource
    15:34:56.375 INFO [Catalina] Server startup in 5641 ms
    15:35:19.593 INFO [JdbcTransactionObjectSupport] JDBC 3.0 Savepoint class is available
    AbandonedObjectPool is used (org.apache.commons.dbcp.AbandonedObjectPool@89db9 a)
    LogAbandoned: false
    RemoveAbandoned: true
    RemoveAbandonedTimeout: 60

    ....and that's it. There is no more log messages

    Questions :

    1. what is wrong with my configuration ? I know it must be something simple, otherwise I would already found it.

    2. are my log4j settings enough ? I need to log
    - start of each transaction
    - commit or rollback

    3. let's say I have my own doWriteToMyOwnLogTable() method in beanAction. Then every time this method is called I want it to issue sql statements in its own transaction , independently of the currently active one. Neither the start nor the termination ( through exception or otherwise ) should have any impact on the current transaction. If I am to code this in jdbc I would establish a totally new connection inside this method and released it afterwards.
    If I'm to code this in spring, what transaction attributes should I use for this method ?
    Anything else ?

    4. is there NNTP server for this newsgroup ?

    I really appreciate the response.