views:

38

answers:

1

Hi. I have a j2ee application running on spring framework. I am trying to apply transaction management using aop but apparently it won't work. I am trying to apply transaction to a function from a class named RegisterBLogic with function name execute(ParamObject obj). My function inserts into a database. I also put a throw ne Exception my function to force the throwing of exception.

Inside userManagerContext:

  <bean id="RegisterBLogic"
     scope="singleton"  
    class="jp.co.anicom.fw.web.usermanager.blogic.RegisterBLogic">
     <property name="queryDAO"
     ref="queryDAO" />   <property
     name="updateDAO" ref="updateDAO" /> 
    </bean>

Inside ApplicationContext

  <bean id="TerasolunaDataSource"  class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="PrototypeDataSource" />
  </bean>
 <tx:advice id="transactionInterceptor" transaction-manager="transactionManager">
   <tx:attributes>
   <tx:method name="insert*" propagation="REQUIRED"
    rollback-for="java.lang.Exception" />
   <tx:method name="execute*" propagation="REQUIRED"
    rollback-for="java.lang.Exception" />
   <tx:method name="*" propagation="REQUIRED" read-only="true" />
  </tx:attributes>
 </tx:advice>
 <!-- AOPの設定 -->
 <aop:config>
  <aop:pointcut id="blogicBeans" expression="bean(*BLogic)" />
  <aop:pointcut id="serviceBeans" expression="bean(*Service)" />
  <aop:advisor pointcut-ref="blogicBeans" advice-ref="transactionInterceptor" />
  <aop:advisor pointcut-ref="serviceBeans" advice-ref="transactionInterceptor" />
 </aop:config>

Yeah these beans already exist. I have this bean declaration under userManagerCOntext.xml. This xml is loaded in the struts config through

 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
  <set-property property="contextConfigLocation"
   value="/WEB-INF/userManager/userManagerContext.xml"/>

 </plug-in>

I found the problem. Currently i am using a data source from a JNDI. class="org.springframework.jndi.JndiObjectFactoryBean">

i changed it to normal data source with property defaultAutoCommit set to false

    <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"
        value="oracle.jdbc.OracleDriver" />
    <property name="url"
        value="jdbc:oracle:thin:@192.168.178.82:1521:anicom" />
    <property name="username" value="jay" />
    <property name="password" value="jay" />
    <property name="initialSize" value="5" />
    <property name="maxActive" value="10" />
    <property name="defaultAutoCommit" value="false" />
           </bean>

How do I use JNDI data source but be able to set a property somewhat similar to defaultAutoCommit to false. I am using Oracle weblogic server and my data source is stored in it accessed through JNDI

+1  A: 

First of all, this XML is malformed (should be </tx:advice>).

Are the beans you want to wrap in AOP already present when this configuration is processed?

Konrad Garus
I have updated my question above.. tnx
cedric
Hi. I have new progress. Kindly check update above. My problem now is when using jndi how do I set a property somewhat similar to defaultAutoCommit and set it to false.
cedric
If you obtain it via JNDI, maybe the other end should initialize it? I mean the place where the JNDI bean is created/registered.
Konrad Garus
something was wrong with my setup in weblogic. but already fixed it. thanks
cedric