0

I have a Gitlab pipeline that calls JMeter from the justb4/jmeter:latest Docker image.

Everything was working fine, but then I forgot when I checked in the latest version of my JMX that I was using the MSSQL JDBC driver which is installed locally, so I get the expected ClassNotFoundException below.

What is the/a correct way to make the relevant DLL and JAR available to my gitlab-ci file?

Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    at org.apache.commons.dbcp2.DriverFactory.createDriver(DriverFactory.java:49)
    at org.apache.commons.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:462)
    at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:528)
    at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:734)
    at org.apache.jmeter.protocol.jdbc.config.DataSourceElement$DataSourceComponentImpl.getConnection(DataSourceElement.java:362)
    at org.apache.jmeter.protocol.jdbc.config.DataSourceElement.getConnection(DataSourceElement.java:198)
    at org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.sample(JDBCSampler.java:80)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.lang.Thread.run(Thread.java:748)
Guy
  • 666
  • 1
  • 10
  • 34

1 Answers1

1

The Microsoft JDBC driver needs to be present in the image you're deploying so you need to create your own Docker image based on the Dockerfile from the justb4/jmeter:latest and add one more line to it between

&& tar -xzf /tmp/dependencies/apache-jmeter-${JMETER_VERSION}.tgz -C /opt  \

and

&& rm -rf /tmp/dependencies

you need to add something like:

&& curl -L --silent https://repo1.maven.org/maven2/com/microsoft/sqlserver/mssql-jdbc/9.4.1.jre8/mssql-jdbc-9.4.1.jre8.jar >  /opt/apache-jmeter-${JMETER_VERSION}/lib  \

Then you need to:

  • build the image
  • tag it using your own image name/version
  • push it to dockerhub
  • replace justb4/jmeter:latest with your own image tag:version

Going forward be aware that you can build a JMeter docker image from scratch yourself without having to rely on other people images, see Make Use of Docker with JMeter - Learn How article for comprehensive information.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • For the next reader's convenience, you would also add this if you want Windows Authentication: `&& curl -L --silent https://repo1.maven.org/maven2/com/microsoft/sqlserver/mssql-jdbc_auth/9.4.1.x86/mssql-jdbc_auth-9.4.1.x86.dll > /opt/apache-jmeter-${JMETER_VERSION}/lib \` – Guy Jan 05 '22 at 08:44