Forum Discussion

Yurie's avatar
Yurie
New Contributor
3 years ago

JDBC connections in docker containers

I am using the smartbear/soapuios-testrunner container image.
I am trying to make a JDBC connection to postgres, but I get an error.
What I have done is


1. put postgresql-42.5.0.jar in the ext folder
2. start the docker container


Command:

docker run --add-host localhost:192.168.12.12 --rm \
-v="<projectFolder>":/project \
-v="<reportFolder>":/reports \
-v="<extFolder>/ext":/ext \
-e COMMAND_LINE="/%project%/soapuiProject.xml -r -M -f /%reports% \
-it smartbear/soapuios-testrunner:latest

Groovy Script:

import groovy.sql.Sql

def driver = 'org.postgresql.Driver'
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver(driver);

Map batchDBConnParams = [
user:'username',
password:'password',
url:'jdbc:postgresql://host:post/dbname',
driver: 'org.postgresql.Driver'
]
def conn = Sql.newInstance(batchDBConnParams);


Error:

ERROR [SoapUI] An error occurred [org.postgresql.Driver], see error log for details
05:32:26,270 ERROR [errorlog] java.lang.ClassNotFoundException: org.postgresql.Driver
java.lang.ClassNotFoundException: org.postgresql.Driver
	at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636) ~[?:?]
	at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
	at java.lang.Class.forName0(Native Method) ~[?:?]
	at java.lang.Class.forName(Class.java:375) ~[?:?]
	at groovy.sql.Sql.loadDriver(Sql.java:733) ~[groovy-sql-3.0.6.jar:3.0.6]
	at groovy.sql.Sql.newInstance(Sql.java:567) ~[groovy-sql-3.0.6.jar:3.0.6]
	at groovy.sql.Sql$newInstance.call(Unknown Source) ~[?:?]
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-3.0.6.jar:3.0.6]
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-3.0.6.jar:3.0.6]
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) ~[groovy-3.0.6.jar:3.0.6]
	at Script1.run(Script1.groovy:47) ~[?:?]
	at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90) ~[soapui-5.7.0.jar:5.7.0]
	at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:143) [soapui-5.7.0.jar:5.7.0]
	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:211) [soapui-5.7.0.jar:5.7.0]
	at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47) [soapui-5.7.0.jar:5.7.0]
	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:138) [soapui-5.7.0.jar:5.7.0]
	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:46) [soapui-5.7.0.jar:5.7.0]
	at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129) [soapui-5.7.0.jar:5.7.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
	at java.lang.Thread.run(Thread.java:831) [?:?]

 

Can anyone help me here ?

  • I solved it myself.

    Changed the volume destination of the ext folder in docker command.

    -v="<extFolder>/ext":$SOAPUI_HOME/ext
  • Yurie's avatar
    Yurie
    New Contributor

    I solved it myself.

    Changed the volume destination of the ext folder in docker command.

    -v="<extFolder>/ext":$SOAPUI_HOME/ext