Forum Discussion

Ditto's avatar
Ditto
New Contributor
8 years ago

Maven + SoapUI ClassNotFoundException(com.microsoft.sqlserver.jdbc.SQLServerDriver)

Hi Guy's, need a little bit of help with Maven and SoapUI. The long-term plan is to integrate my SoapUI tests with Jenkins, however, i'm unfortunately falling down at the first hurdle, when getting my tests to run with Maven. Whenever I run my SoapUI tests via maven on the command line I keep getting the following error: 

 

2017-09-20 10:03:06,977 ERROR [errorlog] java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at groovy.sql.Sql.loadDriver(Sql.java:701)
at groovy.sql.Sql.newInstance(Sql.java:483)
at groovy.sql.Sql$newInstance.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at Script1.run(Script1.groovy:13)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:100)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:154)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:52)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:152)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

 

Now, As far as I'm aware I have included all the necessary dependencies. Here is a copy of my pom file. It's a simple one, I've borrowed from the internet and tweaked the usual bit.

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.smartbear.samples</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 SoapUI Sample</name>
<url>http://maven.apache.org</url>
<pluginRepositories>
<pluginRepository>
<id>SmartBearPluginRepository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.0.0</version>
<configuration>
<outputFolder>logs</outputFolder>
<printReport>true</printReport>
<junitReport>true</junitReport>
<projectFile>Waste-Expert-Admin-Service-API-soapui-project.xml</projectFile>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

 

Can anybody spot any obvious mistake I've made? have I missed something?

  • Ditto's avatar
    Ditto
    New Contributor

    I found the answer (https://stackoverflow.com/questions/19537396/missing-artifact-com-microsoft-sqlserversqljdbc4jar4-0) - I needed to use one of the following in my POM File:

    <!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
    <dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>6.1.0.jre8</version>
    </dependency>
    or for java 7:
    ---------------------------------------------------------
    <!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
    <dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>6.1.0.jre7</version>
    </dependency>

  • NamrataMane's avatar
    NamrataMane
    Occasional Contributor

    Hello All,

     

    I am also facing the issue while executing the ready API script file in VSTS release

     

    java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver error

     


    import groovy.sql.Sql

    def dbURL= "jdbc:sqlserver://servername:1433;databaseName=abcd"
    def dbUsername= "ffff"
    def dbPassword= "ffff!"
    def dbDriver= "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    def db = Sql.newInstance(dbURL,dbUsername,dbPassword,dbDriver)

    def List1 =[]
    def index = 0

    /**********************Select query*******************************/

    def q1 = "select ITEM_ID, * from ITEM_PROPERTY"
    // interact with DB
    try{
    //log.info(q1)

    //db.eachRow(q1){

    //if(qa)
    //log.info "${it.ITEM_ID}"
    log.info("Database connection successful")

    //}
    }catch(InstantiationException e){
    log.info "Some db error"
    log.info e.getMessage()
    }finally{
    // close database connection
    db.close()
    }

     

    The script is working fine in tool. could someone please help....