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

Ludovic Orban (JIRA) noreply at atlassian.com
Sat Feb 20 06:34:48 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35653#action_35653 ] 

Ludovic Orban commented on HHH-3739:
------------------------------------

Please remember that you have to change the 'jndiUserTransactionName' property to something else than the default value so that it doesn't start with the 'java:' prefix anymore, for instance you can call it 'bitronixUserTransaction'.

See http://docs.codehaus.org/display/BTM/Configuration13#Configuration13-Transactionenginesettings


> 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