Using jtds and NTLM authentication to connect to a database with JIRA 4.4+
Symptoms
- During startup JIRA throws a BlankStringArgumentException.
- The database connection doesn't work.
The following appears in the atlassian-jira.log
:
2011-08-05 17:33:36 Commons Daemon procrun stdout initialized2011-08-05 17:33:40,314 main INFO [jira.config.database.SystemTenantDatabaseConfigurationLoader] Reading database configuration from E:\Program Files (x86)\Atlassian\Application Data\JIRA\dbconfig.xml
2011-08-05 17:33:40,673 main ERROR [atlassian.jira.startup.LauncherContextListener] Unable to start JIRA.
com.atlassian.jira.util.dbc.Assertions$NullArgumentException: username should not be null!
at com.atlassian.jira.util.dbc.Assertions.notNull(Assertions.java:26)
Diagnosis
This will only occur in the following environment:
- JIRA 4.4+
- jtds
- NTLM authentication
Cause
In JIRA 4.4 and above we changed how the database configuration is stored to make it easier for 99% of our users to configure a database. In addition this has made it easier for the installer to perform automatic upgrades.
Unfortunately for people that rely on the fairly rare configuration outlined in this KB, the setup of the database configuration has to be a bit more complicated.
Resolution
Since JIRA 4.4+ uses the dbconfig.xm
l file for database deployment and connection, we would have to use the JNDI option to cater for this environment.
In your
dbconfig.xml
, use the following only:<?xml version="1.0" encoding="UTF-8"?> <jira-database-config> <name>defaultDS</name> <delegator-name>default</delegator-name> <database-type>mssql</database-type> <schema-name>YOUR_SCHEMA</schema-name> <jndi-datasource> <jndi-name>java:comp/env/jdbc/JiraDS</jndi-name> </jndi-datasource> </jira-database-config>
Insert this code into your
server.xml
(which should be similar to your previous 4.0 configuration):<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://YOUR_DB_URL/DB_NAME;domain=YOURDOMAIN;instance=INSTANCE;" maxActive="20" minIdle="4" maxIdle="8" validationQuery="Select 1" />
This configuration is not recommended as future upgrades would be quite tedious since they would require for the datasources to be created in server.xml every time.