Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Bitronix Transaction Manager
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h1>Embedded JNDI provider</h1> <p>BTM is bundled with a read-only JNDI provider since version 1.3. You can use it as a convenience as it sometimes facilitates integration with some frameworks in non-application server environments.</p> <p>Using the JNDI provider is obviously not mandatory. As long as you do not use it, it won't conflict with any other JNDI provider nor consume any resource.</p> <h4>Contents</h4> <img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e3RvYzptYXhMZXZlbD0zfG1pbkxldmVsPTJ9&locale=en_GB&version=2" data-macro-name="toc" data-macro-parameters="maxLevel=3|minLevel=2"> <h2>Accessing resources and transaction manager via JNDI</h2> <p>You can access configured resources (JMS and JDBC) as well as the transaction manager from the JNDI provider.</p> <p>Here is the quick way to lookup resources from it:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "bitronix.tm.jndi.BitronixInitialContextFactory"); Context ctx = new InitialContext(env); DataSource ds = (DataSource) ctx.lookup("myDataSourceUniqueName"); UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction"); </pre></td></tr></table> <p>This expects that you configured one JDBC datasource with unique name <code>myDataSourceUniqueName</code>. Resources are automatically bound when created and unbound when closed.</p> <p>The transaction manager itself (which implements both <code>UserTransaction</code> and <code>TransactionManager</code> interfaces) is available by default under the standard <code>java:comp/UserTransaction</code> name.</p> <h2>Changing the default transaction manager's JNDI name</h2> <p>Sometimes it is desirable to bind the transaction manager under a different name than the standard <code>java:comp/UserTransaction</code> one, for instance when there already is a JNDI URL handler configured for <code>java:</code>, like in most application servers.</p> <p>It is recommended that you bind BTM and it resources in the application server's JNDI server but in case you don't want to or can't, you can still use BTM's JNDI provider and bind the transaction under another name by setting this configuration property (see <a href="http://docs.codehaus.org/display/BTM/Configuration13#Configuration13-Transactionenginesettings">here</a> for more details):</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> bitronix.tm.jndi.userTransactionName=btmTransactionManager </pre></td></tr></table> <h2>Configuring BTM's JNDI provider as the default one</h2> <p>You just have to create a <code>jndi.properties</code> file in your classpath with this content:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory </pre></td></tr></table> <p>and then you don't have to specify an environment when creating an <code>InitialContext</code>:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup("myDataSourceUniqueName"); UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction"); </pre></td></tr></table> <p>See <a href="http://btm.codehaus.org/api/1.3.3/bitronix/tm/jndi/BitronixInitialContextFactory.html">BitronixInitialContextFactory</a> for more details.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced