java: Dropping the prefix

(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.


3 thoughts on “java: Dropping the prefix

  1. 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.

  2. 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:

    WARN  - cannot register object with name,UniqueName=java:XAOracleDS,Id=0 cannot build ObjectName with,UniqueName=java:XAOracleDS,Id=0
    Caused by: Invalid character ':' in value part of property

    but when I do disable JMX it works fine.
    Thanks for the help!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.