java: Dropping the prefix
Posted by danielmeyer on August 21, 2008
(Usually it’s good to drop one’s pretensions, but since all we have handy is a prefix we’ll just drop that instead…)
We are (for the moment, anyway) going to need to change our JBoss JDBC datasources so that the datasource resides in the global JNDI namespace, to be looked up under jndi-name Blah rather than java:Blah. The reason we need to make this change is that Bitronix doesn’t currently support the java: prefix.
I seem to remember seeing a tag that you could put in your datasource configuration file that would tell JBoss to make the datasource available from the global JNDI namespace instead of from the JVM-specific java: one.
Ah yes, the JBoss 4 Application Server Guide and the DTD both document the use-java-context element. Set that to false and it goes in the global JNDI namespace. Using the java: namespace would be preferred; The JBoss 4 Application Server Guide also says,
DataSource wrappers are not usable outside of the server VM, so they are normally bound under the java:/, which isn’t shared outside the local VM.
That’s what we’ll need to set in our production datasources so that Bitronix Transaction Manager can exactly replicate the JNDI functionality at integration test time.
Ludovic Orban said
I did not say the java: prefix cannot work. It’s just that if you have multiple JNDI providers installed in your JVM it could be that one of them is going to register a handler for the java: prefix and take precedence over BTM’s.
If you can guarantee BTM’s JNDI provider is the only one in the JVM, using unique names with the java: prefix can work, you just have to disable JMX then (add a disableJmx property with value ‘true’ to the BTM config).
I agree my response in the forum was a bit vague but I didn’t know what the problem was so I just recommended you against doing that to eliminate potential problems.
danielmeyer said
I made your suggested change (adding
<property name="disableJmx" value="true" />to the btmConfig bean), changed the uniqueName values to include a java: prefix, and changed my jndi-lookup beans accordingly, and it works!I think I was missing the part about disabling JMX. When I don’t disable JMX, I get:
but when I do disable JMX it works fine.
Thanks for the help!
danielmeyer said
Update: The disableJmx workaround should not be needed as of of BTM release 1.3.1 (see BTM-26).