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.

Advertisements

, , , ,

  1. #1 by Ludovic Orban on August 21, 2008 - 12:50 pm

    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. #2 by danielmeyer on August 21, 2008 - 1:21 pm

    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  bitronix.tm.utils.ManagementRegistrar  - cannot register object with name bitronix.tm:type=JdbcPooledConnection,UniqueName=java:XAOracleDS,Id=0
    bitronix.tm.internal.BitronixRuntimeException: cannot build ObjectName with name=bitronix.tm:type=JdbcPooledConnection,UniqueName=java:XAOracleDS,Id=0
    ...
    Caused by: javax.management.MalformedObjectNameException: Invalid character ':' in value part of property
    

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

  3. #3 by danielmeyer on December 18, 2008 - 10:00 am

    Update: The disableJmx workaround should not be needed as of of BTM release 1.3.1 (see BTM-26).

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s