jTDS driver properties setting

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

jTDS driver properties setting

mdessure
I tried to set the lobBuffer property of the jTDS driver for MS SQL Server 2005 and it looks like BTM is unable to convert a string to a long value.

The property in question is lobBuffer, which requires a number. If I remove this property from the configuration file, everything works perfectly.


My configuration (properties) file looks like this:

bitronix.tm.serverId=sosgi
bitronix.tm.2pc.async=false
bitronix.tm.2pc.warnAboutZeroResourceTransactions=false

# Disk journal properties -- we take the defaults
bitronix.tm.journal.disk.logPart1Filename=log/btm1.tlog
bitronix.tm.journal.disk.logPart2Filename=log/btm2.tlog
bitronix.tm.timer.defaultTransactionTimeout=120
bitronix.tm.timer.gracefulShutdownInterval=5
bitronix.tm.timer.backgroundRecoveryInterval=0

bitronix.tm.resource.configuration=conf/bitronix-jta/btm-config.properties
bitronix.tm.resource.bind=false

resource.cfgmgmt.className=net.sourceforge.jtds.jdbcx.JtdsDataSource
resource.cfgmgmt.uniqueName=cfgmgmt
resource.cfgmgmt.minPoolSize=5
resource.cfgmgmt.maxPoolSize=40
resource.cfgmgmt.acquireIncrement=1
resource.cfgmgmt.useTmJoin=true
resource.cfgmgmt.deferConnectionRelease=true
resource.cfgmgmt.automaticEnlistingEnabled=true
resource.cfgmgmt.acquisitionTimeout=30
resource.cfgmgmt.acquisitionInterval=2
resource.cfgmgmt.allowLocalTransactions=true
resource.cfgmgmt.testQuery=SELECT 1
resource.cfgmgmt.driverProperties.lobBuffer=256000
resource.cfgmgmt.driverProperties.charset=UTF-8
resource.cfgmgmt.driverProperties.user=username
resource.cfgmgmt.driverProperties.password=password
resource.cfgmgmt.driverProperties.databaseName=dbname
resource.cfgmgmt.driverProperties.serverName=localhost
resource.cfgmgmt.driverProperties.portNumber=1433


The exception I get is the following:

bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named cfgmgmt
        at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:50)
        at bitronix.tm.resource.ResourceLoader.initXAResourceProducers(ResourceLoader.java:161)
        at bitronix.tm.resource.ResourceLoader.init(ResourceLoader.java:132)
        at bitronix.tm.resource.ResourceLoader.init(ResourceLoader.java:62)
        at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:48)
        at bitronix.tm.TransactionManagerServices.getTransactionManager(TransactionManagerServices.java:43)
        at org.ziptie.zap.jta.internal.JtaActivator.start(JtaActivator.java:67)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:252)
        at org.ziptie.crates.CrateStarterElf.start(CrateStarterElf.java:272)
        at org.ziptie.crates.CrateStarterElf.activateBundles(CrateStarterElf.java:197)
        at com.alterpoint.sosgi.bootstrap.BootstrapActivator.start(BootstrapActivator.java:60)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:350)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1118)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:634)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:508)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:282)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:468)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:195)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:297)
Caused by: bitronix.tm.utils.PropertyException: cannot convert values of type 'java.lang.String' into type 'long'
        at bitronix.tm.utils.PropertyUtils.transform(PropertyUtils.java:229)
        at bitronix.tm.utils.PropertyUtils.setDirectProperty(PropertyUtils.java:189)
        at bitronix.tm.utils.PropertyUtils.setProperty(PropertyUtils.java:51)
        at bitronix.tm.resource.common.XAPool.createXAFactory(XAPool.java:223)
        at bitronix.tm.resource.common.XAPool.<init>(XAPool.java:47)
        at bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:59)
        at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:48)

Clearly all properties set via a properties file will in be string format and btm should try to convert the string into the desire format (in this case a long) when needed instead of throwing an exception. I would understand getting an exception if the value couldn't be converted to a long but in this case, I think I stepped on a bug.

Is this something not supported? How can you set driver properties, other than string values using a properties configuration file?

I welcome any suggestions.
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

danielmeyer
mdessure wrote
How can you set driver properties, other than string values using a properties configuration file?
If you're in a Spring environment you can use Spring beans (see the BTM instructions for Spring) -- or if you're in an environment where you don't mind manipulating the datasource object directly via code, you can set driver properties on the PoolingDataSource using getDriverProperties().setProperty() (see setProperty in the BTM new user guide).

But you're right, this sounds like a bug.

-Daniel-
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

Ludovic Orban
Administrator
In reply to this post by mdessure
Hi,

This is a limitation of the resource creation code. I never encountered (and even expected) an XADataSource implementation that would require something else than boolean, integer or String before so support for other types has been left out.

I've created an issue about it: http://jira.codehaus.org/browse/BTM-30

Support for setting and getting all primitive types has now been added, the fix is available in the trunk. You can build the latest sources yourself or get back to me if you want me to make a snapshot build.

Thanks for reporting the issue.
Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

Ludovic Orban
Administrator
In reply to this post by danielmeyer
No, that won't work because BTM still has to transform Strings into primitives internally.

Spring will only fill the Properties object of the PoolingDataSource (see:http://btm.codehaus.org/api/1.3/bitronix/tm/resource/common/ResourceBean.html#setDriverProperties(java.util.Properties) ). It's up to BTM to transform the Strings of the driverProperties into types needed by the vendor's XADataSource.

Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

danielmeyer
I see.  Well, I tried!  
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

danielmeyer
In reply to this post by Ludovic Orban

Ludovic Orban wrote
No, that won't work because BTM still has to transform Strings into primitives internally.
Come to think of it though, once someone has your fix, my ways would work, right?
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

mdessure
In reply to this post by Ludovic Orban
Thanks Ludovic for validating that this is an issue. I'm using BTM 1.2; Is it possible to get a patch?

Thanks again.

-Martin

Ludovic Orban wrote
Hi,

This is a limitation of the resource creation code. I never encountered (and even expected) an XADataSource implementation that would require something else than boolean, integer or String before so support for other types has been left out.

I've created an issue about it: http://jira.codehaus.org/browse/BTM-30

Support for setting and getting all primitive types has now been added, the fix is available in the trunk. You can build the latest sources yourself or get back to me if you want me to make a snapshot build.

Thanks for reporting the issue.
Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

Ludovic Orban
Administrator
Upgrading to 1.3 should be straightforward. Is there any particular reason why you want to stick with 1.2 ?

I don't feel like releasing a 1.2.1 version as this would be a lot of work, unless you're willing to pay support for that.

As a trade off, I can send you a patch for the 1.2 version you'd have to apply and build yourself.

Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

mdessure
If it is fixed in 1.3, I have no problem upgrading to that version as long as it is a "released" version.

-Martin

Ludovic Orban wrote
Upgrading to 1.3 should be straightforward. Is there any particular reason why you want to stick with 1.2 ?

I don't feel like releasing a 1.2.1 version as this would be a lot of work, unless you're willing to pay support for that.

As a trade off, I can send you a patch for the 1.2 version you'd have to apply and build yourself.

Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

Ludovic Orban
Administrator
Well, actually not. The bug exists in all released versions.

I'm sorry but you'll have to wait for version 1.3.1.

Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

mdessure
Thats no problem... do you have an ETA on when 1.3.1 will be GAed?

-Martin

Ludovic Orban wrote
Well, actually not. The bug exists in all released versions.

I'm sorry but you'll have to wait for version 1.3.1.

Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

Ludovic Orban
Administrator
Well, the roadmap say sometime in September.

I've just passed through the open bugs / requests list and managed to close them all today so I think it is realistic to expect 1.3.1 to be released by the end of this month.

Could you please test the fix I implemented in the meantime ? I want to make sure there is nothing you're expecting that I could have missed.

Thanks,
Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

mdessure
I would love to test the fix but unfortunately, the trunk doesn't compile for me... I guess (without spending time investigating why) it's because I have jdk 1.6 and you require 1.4? Anyway, if you can make the 1.3.1 (beta) available somewhere, I'll be happy to pick it up and try it out. You can also send it to me by email if you prefer.

- Martin

FYI, here is the stacktrace

build:
    [mkdir] Created dir: C:\Projects\bitronix\trunk\dist\classes
    [javac] Compiling 115 source files to C:\Projects\bitronix\trunk\dist\classes
    [javac] C:\Projects\bitronix\trunk\src\bitronix\tm\resource\jdbc\JdbcConnectionHandle.java:18: bitronix.tm.resource.jdbc.JdbcConnectionHandle is not abstract and does not override abstract method createStruct(java.lang.String,java.lang.Object[]) in java.sql.Connection
    [javac] public class JdbcConnectionHandle implements Connection {
    [javac]        ^
    [javac] C:\Projects\bitronix\trunk\src\bitronix\tm\resource\jdbc\PoolingDataSource.java:28: bitronix.tm.resource.jdbc.PoolingDataSource is not abstract and does not override abstract method isWrapperFor(java.lang.Class) in java.sql.Wrapper
    [javac] public class PoolingDataSource extends ResourceBean implements DataSource, XAResourceProducer {
    [javac]        ^
    [javac] C:\Projects\bitronix\trunk\src\bitronix\tm\resource\jdbc\JdbcPreparedStatementHandle.java:19: bitronix.tm.resource.jdbc.JdbcPreparedStatementHandle is not abstract and does not override abstract method setNClob(int,java.io.Reader) in java.sql.PreparedStatement
    [javac] public class JdbcPreparedStatementHandle implements PreparedStatement {
    [javac]        ^
    [javac] C:\Projects\bitronix\trunk\src\bitronix\tm\resource\jdbc\lrc\LrcConnectionHandle.java:12: bitronix.tm.resource.jdbc.lrc.LrcConnectionHandle is not abstract and does not override abstract method createStruct(java.lang.String,java.lang.Object[]) in java.sql.Connection
    [javac] public class LrcConnectionHandle implements Connection {
    [javac]        ^
    [javac] C:\Projects\bitronix\trunk\src\bitronix\tm\resource\jdbc\lrc\LrcXAConnection.java:21: bitronix.tm.resource.jdbc.lrc.LrcXAConnection is not abstract and does not override abstract method removeStatementEventListener(javax.sql.StatementEventListener) in javax.sql.PooledConnection
    [javac] public class LrcXAConnection implements XAConnection {
    [javac]        ^
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] 5 errors

BUILD FAILED
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

Ludovic Orban
Administrator
Hi,

This is a well-know problem: the sources can only be built with JDK 1.4.2. I've built and released BTM 1.3.1 beta1 as a convenience to you and other people who reported bugs.

The BTM 1.3.x versions will probably be the last ones supporting JDK 1.4.2 as Sun will make it EOL by the end of next month. This will allow me to upgrade JDK 1.5 and hopefully make the source code buildable with JDK 1.5+.

Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

mdessure
Thanks again Ludovic... This saves me a jdk 1.4.2 installation.
However, I can't find where you put the 1.3.1 version available for download. Can you post a url where to get the jar from?

Thanks,

-Martin

Ludovic Orban wrote
Hi,

This is a well-know problem: the sources can only be built with JDK 1.4.2. I've built and released BTM 1.3.1 beta1 as a convenience to you and other people who reported bugs.

The BTM 1.3.x versions will probably be the last ones supporting JDK 1.4.2 as Sun will make it EOL by the end of next month. This will allow me to upgrade JDK 1.5 and hopefully make the source code buildable with JDK 1.5+.

Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

Ludovic Orban
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: jTDS driver properties setting

mdessure
It works like a charm... Thanks Ludovic for all your work on this.

-Martin