We want to connect to external databases using the Microsoft SQL Server Driver. This driver is present in our environment already and testing shows we can obtain an instance of it and operate on SQL just fine. Great.
However, we seem to be completely unable to get this to work in the Atlassian SDK using atlas-run or atlas-debug. We’ve tried to declare maven dependencies, BND instructions, datasource configurations on the amps plugin, just dragging and dropping the file in the class path …
We’re at our wits end to get this to work in the SDK: Does anyone have any advice? How can we instruct the SDK to deploy a Database Driver that we can obtain in-app with Class.forName(String str)
?
Maybe you have already thought of that but you could also develop using atlas-run-standalone
or an actual installation of Jira on your system.
With these two it’s super easy to use jars that you manually put in.
I had not considered that. I will test that out and report back. Thank you for the suggestion.
1 Like
I tried to resolve this issue by using atlas-run-standalone and I’m still getting a java.lang.ClassNotFoundException when calling Class.forName. Here are the specific steps that I have taken:
- Deployed a standalone Jira instance by calling atlas-run-standalone.
- Put the driver .jar file (mssql-jdbc-6.2.2.jre8.jar) in target\jira\webapp\WEB-INF\lib.
- Restarted standalone Jira instance.
- Deployed my plug-in.
- Attempted to perform a Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”) call with my plug-in.
- Received java.lang.ClassNotFoundException.
What’s interesting is that I’m able to call ClassLoaderUtils.loadClass to get a handle to the driver. Subsequently calling DriverManager.getConnection(CONNECTION_STRING) results in a “java.sql.SQLException: No suitable driver found” error.
I was finally able to get this working in my Atlassian SDK by making some updates to the dependencies in pom.xml.
First, I added the driver as a compile dependency.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.2.2.jre8</version>
</dependency>
Second, I added the following entry inside of the <Import-Package> declaration.
*;version="0";resolution:="optional"
After performing an atlas-clean, I’m able to use atlas-run and atlas-debug with no issues. I’m now able to call Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”) and get a handle to the driver.
4 Likes