Announcement Announcement Module
No announcement yet.
WebSphereTransactionManagerFactoryBean error - "comp/UserTransaction" not found Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • WebSphereTransactionManagerFactoryBean error - "comp/UserTransaction" not found

    We am trying to use spring transactions on Websphere 5 (5.02.9) and keep getting the following error when we try run code that requires a transaction:

    org.springframework.transaction.TransactionSystemE xception: JTA UserTransaction is not available at JNDI location [java:co
    mp/UserTransaction]; nested exception is javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".

    We have configured the transaction manager in the application context as follows:

    <bean id="websphereTransactionFactory" class="org.springframework.transaction.jta.WebSphe reTransactionManagerFactoryBean"/>

    <bean id="websphereTransactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
    <property name="transactionManager">
    <ref local="websphereTransactionFactory"/>

    Which, according to the javadoc, should work. Where is websphere keeping it's user transactions and is there some way I can find this out and then specify the WebSphereTransactionManagerFactoryBean to look at a different location maybe? Or have I misconfigured something?

    Any help, clues etc. would be greatly appreciated!

  • #2
    I'm having the same problem with Websphere 5.1.2. Have you a solution to this problem?


    • #3
      I'm afraid we didn't find a solution to the problem and I received no replies on this forum either. After much trial and error we had to give up and go back to manually coding user transactions ourselves


      • #4
        We're still looking for a resolution to this problem. Our next step is to try WebSphereTransactionManagerLookup class from hibernate. Do you have any other ideas?


        • #5
          The following configuration should solve the problem:

          <bean id="wsJtaTm" class="org.springframework.transaction.jta.WebSphe reTransactionManagerFactoryBean"/>

          <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager" >
          <property name="userTransactionName"><null /></property>
          <property name="transactionManager" ref="wsJtaTm" />

          Please inform us about your testing results.


          • #6
            Although stated differently in the documentation, WebSphere 5.1 binds the UserTransaction not under "comp/UserTransaction" but still unter the somewhat oldfashioned name ""jta/usertransaction". You can verify this by using the "dumpNameSpace.bat" utility in the WebSphere-bin directory...



            • #7
              The IBM InfoCenter for WebSphere states that the server no longer provides the UserTransaction at jta/usertransaction as of version 5.

              In addition, the UserTransaction is not available from any location, including comp/UserTransaction, to CMT EJBs.


              I managed to get this similar situation to work with the following:

              	<bean id="wsJtaTm" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/>
              	<bean id="myTxManager" class="org.springframework.transaction.jta.JtaTransactionManager">
              		<property name="userTransactionName"><null /></property>
              		<property name="transactionManager" ref="wsJtaTm"/>


              • #8
                I'm running WAS 5.1 fixpack 3 and am still seeing jta/usertransaction when I run dumpnamespace. Is there somthing I have to do to get it to switch to using java:com/UserTransaction?


                • #9
                  There isn't anything you can/should have to do. WebSphere will always provide a UserTransaction at java:comp/UserTransaction. However, If you're running a container-managed transaction component like a stateless session EJB, WebSphere will not make the UserTransaction available, period. Same goes for a client application running outside of WebSphere.


                  • #10
                    If your Spring is loaded inside an EJB, you must define BMT for that EJB so that WebSphere makes the UserTransaction available, just like mphartman said.

                    I had problems using WebSphereTransactionManagerFactoryBean in WSAD test server, and the reason turned out to be that the test server has a different classloader hierarchy than the WAS server, and Class.forName() does not work in the test server because (in my configuration) the spring.jar was loaded by a parent loader to the one loading the IBM classes (like So I made a modified version of WebSphereTransactionManagerFactoryBean that uses the Thread.currentThread().getContextClassLoader() classloader. The code below:

                    public class WebSphereTransactionManagerFactoryBean implements FactoryBean {
                        private static final String FACTORY_CLASS_5_1 = "";
                        private static final String FACTORY_CLASS_5_0 = "";
                        private static final String FACTORY_CLASS_4 = "";
                        protected final Log logger = LogFactory.getLog(getClass());
                        private final TransactionManager transactionManager;
                         * This constructor retrieves the WebSphere TransactionManager factory class,
                         * so we can get access to the JTA TransactionManager.
                        public WebSphereTransactionManagerFactoryBean() throws TransactionSystemException {
                            ClassLoader cl = Thread.currentThread().getContextClassLoader(); // NEW
                            Class clazz; // NEW
                            try {
                                logger.debug("Trying WebSphere 5.1+: " + FACTORY_CLASS_5_1);
                                clazz = cl.loadClass(FACTORY_CLASS_5_1); // NEW
                    //            clazz = Class.forName(FACTORY_CLASS_5_1);
                      "Found WebSphere 5.1+: " + FACTORY_CLASS_5_1);
                            catch (ClassNotFoundException ex) {
                                logger.debug("Could not find WebSphere 5.1/6.0 TransactionManager factory class", ex);
                                try {
                                    logger.debug("Trying WebSphere 5.0: " + FACTORY_CLASS_5_0);
                                    clazz = cl.loadClass(FACTORY_CLASS_5_0); // NEW
                    //                clazz = Class.forName(FACTORY_CLASS_5_0);
                          "Found WebSphere 5.0: " + FACTORY_CLASS_5_0);
                                catch (ClassNotFoundException ex2) {
                                    logger.debug("Could not find WebSphere 5.0 TransactionManager factory class", ex2);
                                    try {
                                        logger.debug("Trying WebSphere 4: " + FACTORY_CLASS_4);
                                        clazz = cl.loadClass(FACTORY_CLASS_4); // NEW
                    //                    clazz = Class.forName(FACTORY_CLASS_4);
                              "Found WebSphere 4: " + FACTORY_CLASS_4);
                                    catch (ClassNotFoundException ex3) {
                                        logger.debug("Could not find WebSphere 4 TransactionManager factory class", ex3);
                                        throw new TransactionSystemException(
                                                "Could not find any WebSphere TransactionManager factory class, " +
                                                "neither for WebSphere version 5.1+ nor 5.0 nor 4");
                            try {
                                Method method = clazz.getMethod("getTransactionManager", (Class[]) null);
                                this.transactionManager = (TransactionManager) method.invoke(null, (Object[]) null);
                            catch (InvocationTargetException ex) {
                                throw new TransactionSystemException(
                                        "WebSphere's TransactionManagerFactory.getTransactionManager method failed", ex.getTargetException());
                            catch (Exception ex) {
                                throw new TransactionSystemException(
                                        "Could not access WebSphere's TransactionManagerFactory.getTransactionManager method", ex);
                        public Object getObject() {
                            return this.transactionManager;
                        public Class getObjectType() {
                            return this.transactionManager.getClass();
                        public boolean isSingleton() {
                            return true;
                    Could this be changed to the Spring implementation, or are there downsides to this solution?