Announcement Announcement Module
Collapse
No announcement yet.
Websphere 6 JTA question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Websphere 6 JTA question

    I want to have a transaction on a method which
    a. saves data using hibernate AND
    b. Calls a session bean method in Websphere which sends a message to MQ

    So, this is like a XA transaction in Websphere.

    So, would a Spring tansaction manager alone do this? Or should I use Websphere's JTA?

    But, when I went thro' Spring API for Websphere JTA support, it said that there is only support for Websphere version 5 and 4 etc. It does not support Websphere 6.

    Did anybody have this issue? How did you get over?

    Any help is appreciated.

    Thanks

  • #2
    I've only implemented JPetstore on websphere 6 using the JTA. You can use the default JTATransactionManger if you don't need to suspend the transaction

    From:
    http://www.springframework.org/docs/...onManager.html
    For typical JTA transactions (REQUIRED, SUPPORTS, MANDATORY, NEVER), a plain JtaTransactionManager definition is all you need, completely portable across all J2EE servers.
    Sorry, I don't have more information on this...

    Dino

    Comment


    • #3
      Thanks a lot for your help. I will try it and let you know.

      Thanks

      Comment


      • #4
        Hi hucmuc,
        Can you please tell me the name of the transactionManager for Websphere that you set.

        Thanks

        Comment


        • #5
          Actually, Spring's WebSphereTransactionManagerFactoryBean will properly work on WebSphere 6 as well, even if the javadoc doesn't explicitly say so. It has been tested on WebSphere 6, which still uses WebSphere 5.1's corresponding API: Hence, WebSphereTransactionManagerFactoryBean will detect WebSphere 6 as "WebSphere 5.1". I've updated the log messages and our docs accordingly, indicating that it's actually WebSphere 5.1+.

          Note that Spring's JtaTransactionManager will continue to use the JTA UserTransaction for standard transaction demarcation, as defined by standard J2EE. It will only use the provided WebSphere TransactionManager in case of actual transaction suspension needs (PROPAGATION_REQUIRES_NEW, PROPAGATION_NOT_SUPPORTED).

          Juergen

          Comment


          • #6
            My applicationContext.xml has

            <bean id="userTransaction" class="org.springframework.jndi.JndiObjectFactoryB ean">
            <property name="jndiName">
            <value>comp/UserTransaction</value>
            </property>
            <property name="jndiEnvironment">
            <props>
            <prop
            key="java.naming.factory.initial">com.ibm.webspher e.naming.WsnInitialContextFactory</prop>
            <prop
            key="java.naming.provider.url">iiop://localhost:2809</prop>
            </props>
            </property>
            </bean>

            <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
            <constructor-arg ><ref bean="userTransaction"/></constructor-arg>
            </bean>

            I have also tried in the jndiName the following
            1 <property name="jndiName">
            <value>java:comp/UserTransaction</value>
            </property>

            2 <property name="jndiName">
            <value>UserTransaction</value>
            </property>

            It is not able to find the UserTransaction object in JNDI tree.
            I keep getting the exception

            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'userTransaction' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is javax.naming.NameNotFoundException: Context: pkorwarNode03Cell/nodes/pkorwarNode03/servers/server1, name: comp/UserTransaction: First component in name comp/UserTransaction not found.
            javax.naming.NameNotFoundException: Context: pkorwarNode03Cell/nodes/pkorwarNode03/servers/server1, name: comp/UserTransaction: First component in name comp/UserTransaction not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
            at org.omg.CosNaming.NamingContextPackage.NotFoundHel per.read(NotFoundHelper.java:85)
            at com.ibm.WsnOptimizedNaming._NamingContextStub.reso lve_complete_info(Unknown Source)
            at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve (CNContextImpl.java:4043)
            at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(C NContextImpl.java:1746)
            at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(C NContextImpl.java:1707)
            at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt( CNContextImpl.java:1412)
            at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNC ontextImpl.java:1290)
            at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCt x.java:144)
            at javax.naming.InitialContext.lookup(InitialContext. java:361)
            at org.springframework.jndi.JndiTemplate$1.doInContex t(JndiTemplate.java:123)
            at org.springframework.jndi.JndiTemplate.execute(Jndi Template.java:85)
            at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:121)
            at org.springframework.jndi.JndiLocatorSupport.lookup (JndiLocatorSupport.java:71)
            at org.springframework.jndi.JndiObjectLocator.lookup( JndiObjectLocator.java:106)
            at org.springframework.jndi.JndiObjectFactoryBean.aft erPropertiesSet(JndiObjectFactoryBean.java:125)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:966)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:358)
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
            at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:270)
            at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:312)
            at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:80)
            at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:65)
            at com.tdemand.common.TestHibernate.main(TestHibernat e.java:31)

            Comment


            • #7
              I tried

              <property name="jndiName">
              <value>jta/usertransaction</value>
              </property>

              and it worked. So, hopefully it is right..... :-)

              Comment


              • #8
                Originally posted by Juergen Hoeller View Post
                Actually, Spring's WebSphereTransactionManagerFactoryBean will properly work on WebSphere 6 as well, even if the javadoc doesn't explicitly say so. It has been tested on WebSphere 6, which still uses WebSphere 5.1's corresponding API: Hence, WebSphereTransactionManagerFactoryBean will detect WebSphere 6 as "WebSphere 5.1". I've updated the log messages and our docs accordingly, indicating that it's actually WebSphere 5.1+.

                Note that Spring's JtaTransactionManager will continue to use the JTA UserTransaction for standard transaction demarcation, as defined by standard J2EE. It will only use the provided WebSphere TransactionManager in case of actual transaction suspension needs (PROPAGATION_REQUIRES_NEW, PROPAGATION_NOT_SUPPORTED).

                Juergen
                What about the explicit recommendation to not use Websphere's TransactionManager described in http://www.ibm.com/developerworks/we...09_alcott.html?

                We need to use the Requires New propagation policy with Webphere 6.x but we are not sure it won't affect the environment.

                Comment


                • #9
                  We are also dealing with the same issue as well. It appears that an application at my company is using REQUIRES_NEW in Websphere 5.1. It apparently worked in 5.1, but now that they are trying to upgrade to v6, it no longer works.

                  Supposedly WAS 6.0.2.19 and the latest milestone of Spring 2.1 has an IBM supported way to do this.

                  That IBM article that the previous person mentioned was updated a few weeks ago to include this information. Interestingly enough, IBM has backed off from its position that it does not support message-driven POJOs, which was the major problem I had with the article to begin with.

                  Comment

                  Working...
                  X