[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3739) Problem using BTMTransactionManagerLookup with Tomcat

Helder Sousa (JIRA) noreply at atlassian.com
Thu Jan 29 05:08:54 EST 2009


Problem using BTMTransactionManagerLookup with Tomcat
-----------------------------------------------------

                 Key: HHH-3739
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3739
             Project: Hibernate Core
          Issue Type: Patch
          Components: core
    Affects Versions: 3.3.1
         Environment: Hibernate 3.3.1 GA
            Reporter: Helder Sousa
         Attachments: BTMTransactionManagerLookup.patch

Hi.

When using Bitronix Transaction Manager with tomcat there is a problem resolving the TransactionManager by JNDI. Please take a look to this thread: http://www.nabble.com/Hibernate-JTATransactionFactory-and-BTMTransactionManagerLookup-td21706680.html

In 5th post, Ludovic wrote: "The UserTransaction name is java:comp/UserTransaction and when a JNDI lookup happens in Tomcat, the Tomcat provider takes precedence because Tomcat registered a java: namespace handler."

So, when using BTM in Tomcat, the BTM users should configure in BTM Configuration a JNDI name that does not start with java:comp and the BTMTransactionManagerLookup class should read this configuration: 
Here is the change to the BTMTransactionManagerLookup class  (I attached the patch):

	public String getUserTransactionName() {
		try	{
			Class transactionManagerServiceClass = Class.forName("bitronix.tm.TransactionManagerServices");
			Method getConfigurationMethod = transactionManagerServiceClass.getMethod("getConfiguration", null);
			Object configurationInstance = getConfigurationMethod.invoke(null, null);

			Class bitronixConfigurationClass = configurationInstance.getClass();
			Method getJndiUserTransactionNameMethod = bitronixConfigurationClass
					.getMethod("getJndiUserTransactionName", null);
			String configuredJndiUserTransactionName = (String) getJndiUserTransactionNameMethod.invoke(
					configurationInstance, null);
			if (configuredJndiUserTransactionName != null && configuredJndiUserTransactionName.trim().length() >= 0) {
				return configuredJndiUserTransactionName;
			}
			return "java:comp/UserTransaction";
		}
		catch (Exception e)	{
			throw new HibernateException("Could not obtain BTM UserTransactionName", e);
		}
	}

Can you apply the patch?
Best regards,

Helder Sousa

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list