Forum Discussion

ksorge's avatar
ksorge
New Contributor
7 years ago

How do I add jdbc driver to the ready-api-maven-plugin?

I have created a ReadyAPI project that has a test that connects to a database that I want to run with maven. I was trying the following plugin setup but it doesn't seem to find the JDBC driver.

 

<plugin>
  <groupId>com.smartbear</groupId>
  <artifactId>ready-api-maven-plugin</artifactId>
  <version>2.3.0</version>
  <executions>
    <execution>
      <phase>test</phase>
      <goals>
        <goal>test</goal>
      </goals>
      <configuration>
        <projectFile>${basedir}/src/test/soapui/session-readyapi-project.xml</projectFile>
        <junitReport>true</junitReport>
        <reports>${basedir}/target/surefire-reports</reports>
        <outputFolder>${basedir}/target/surefire-reports</outputFolder>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>mysql</groupId>

      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.11</version>

  </dependency>
  </dependencies>
</plugin>

Would anyone know how to add additional libraries to the maven plugin?

 

 

  • Now if I add a soapui.home directory and put the same jdbc driver in $SOAPUI_HOME/bin/ext the tests pass without error. This is a solution, but I would like to be able to allow developers and testers to only have a vanilla ReadyAPI installation and if additional jars are required for testing for them to be able to use them through the dependency mechanism in Maven.

     

    Thanks

     

  • ksorge's avatar
    ksorge
    New Contributor

    Now if I add a soapui.home directory and put the same jdbc driver in $SOAPUI_HOME/bin/ext the tests pass without error. This is a solution, but I would like to be able to allow developers and testers to only have a vanilla ReadyAPI installation and if additional jars are required for testing for them to be able to use them through the dependency mechanism in Maven.

     

    Thanks

     

  • Nastya_Khovrina's avatar
    Nastya_Khovrina
    SmartBear Alumni (Retired)

    Hi,

     

    Thank you for your message. What error do you get in the output?

    • ksorge's avatar
      ksorge
      New Contributor

      Hi,

       

      Thanks for the reply, it seems I was able to get the mysql-connector to work with adding <scope>runtime</scope> to the dependency. However this does not seem to work the an oracle jdbc driver we have in a local repository. When I change the dependency to :

       

      <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>12.1.0.2.0</version>
        <scope>runtime</scope>
      </dependency>

       

      and in the test change the Driver to oracle.jdbc.OracleDriver, I get the following stacktrace:

       

      java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at com.eviware.soapui.support.GroovyUtils.registerJdbcDriver(GroovyUtils.java:107)
      at com.eviware.soapui.support.jdbc.JdbcUtils.initConnection(JdbcUtils.java:58)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.ProJdbcSubmit.getDatabaseConnection(ProJdbcSubmit.java:18)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.prepare(JdbcSubmit.java:216)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.runQuery(JdbcSubmit.java:173)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.run(JdbcSubmit.java:147)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.<init>(JdbcSubmit.java:79)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.ProJdbcSubmit.<init>(ProJdbcSubmit.java:12)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.ProJdbcRequest.submit(ProJdbcRequest.java:15)
      at com.eviware.soapui.impl.wsdl.teststeps.JdbcRequestTestStep.run(JdbcRequestTestStep.java:209)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:260)
      at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:50)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:170)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:1)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at com.eviware.soapui.support.GroovyUtils.registerJdbcDriver(GroovyUtils.java:107)
      at com.eviware.soapui.support.jdbc.JdbcUtils.initConnection(JdbcUtils.java:58)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.ProJdbcSubmit.getDatabaseConnection(ProJdbcSubmit.java:18)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.prepare(JdbcSubmit.java:216)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.runQuery(JdbcSubmit.java:173)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.run(JdbcSubmit.java:147)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.JdbcSubmit.<init>(JdbcSubmit.java:79)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.ProJdbcSubmit.<init>(ProJdbcSubmit.java:12)
      at com.eviware.soapui.impl.wsdl.panels.teststeps.ProJdbcRequest.submit(ProJdbcRequest.java:15)
      at com.eviware.soapui.impl.wsdl.teststeps.JdbcRequestTestStep.run(JdbcRequestTestStep.java:209)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:260)
      at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:50)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:170)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:1)
      at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)