Missing JDBC Driver

mysql
circle.yml

#1

Hello all,

New to CircleCI but enjoying working with it so far. However, I have run into an issue with my Java API when it starts up for integration testing. During its initialisation, the API connects to a MySQL DB but every time I start it up I am getting this error:

Failed to instantiate [api.BookingController]: Constructor threw exception; nested exception is java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I’ve tried adding the following to kick start things:

Class.forName(“com.mysql.jdbc.Driver”);

Which returns the error you see above. I have also run:

sudo apt-get install libmysql-java

Neither of these things fixed the issue. I have also confirmed that the DB is accessible with mysql-client. Can anyone help, feel like I am missing something obvious.

CircleCi config below

run_integration_tests:

docker:
  - image: circleci/openjdk:8u151-jdk-node-browsers
    environment:
      - MYSQL_DATABASE: "rbp"
      - MYSQL_HOST: "127.0.0.1"
  - image: circleci/mysql:5.7
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: yes
      MYSQL_ROOT_PASSWORD: 'password'

environment:
    MAVEN_OPTS: -Xmx3200m

steps:
  - restore_cache:
      key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}

  - run:
      command: |
        dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
        mysql -h 127.0.0.1 -u root -ppassword < db/setup.sql

  - run:
      command: mvn integration-test
      working_directory: integration-tests

#2

It does not seem to be in your config file, though?


#3

Apologies, that was run during an SSH session to test it out.

I worked out the issue isn’t CircleCI related though and that the way I was starting the API within my integration tests was what was causing the issue. So I moved the startup of the APIs to a shell script and it all worked fine and dandy :slight_smile:


#4

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.