Forum Discussion
maghol
New Contributor
Hey,
I'm trying to modify the classpath with the following code:
But I get a class not found exception when I try to connect to the Oracle Db:
Wed Oct 20 15:54:30 CEST 2010:ERROR:java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at groovy.sql.Sql.loadDriver(Sql.java:467)
at groovy.sql.Sql.newInstance(Sql.java:293)
at groovy.sql.Sql$newInstance.call(Unknown Source)
at Script16.run(Script16.groovy:24)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:87)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I'm using SoapUI Pro 3.6, Build dist-109-2010-09-13, Build Date 2010/09/13 13:46.
It seems that the classpath is not extended. If I copy ojdbc14.jar to the SoapUI/lib dir it works. But I want to avoid that.
I'm trying to modify the classpath with the following code:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def classpathHacker = new com.eviware.soapui.support.ClasspathHacker ()
log.info "utils=" + groovyUtils
path = groovyUtils.getProjectPath()
myfile = new java.io.File(path + "/ojdbc14.jar")
mystring = "file://" + path + "/ojdbc14.jar"
log.info "myfile=" + myfile
classpathHacker.addFile( myfile )
com.eviware.soapui.support.ClasspathHacker.addFile( myfile )
com.eviware.soapui.support.ClasspathHacker.addURL( new URL(mystring) )
import groovy.sql.*
def sql = groovy.sql.Sql.newInstance( db, userid, password, 'oracle.jdbc.driver.OracleDriver' )
But I get a class not found exception when I try to connect to the Oracle Db:
Wed Oct 20 15:54:30 CEST 2010:ERROR:java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at groovy.sql.Sql.loadDriver(Sql.java:467)
at groovy.sql.Sql.newInstance(Sql.java:293)
at groovy.sql.Sql$newInstance.call(Unknown Source)
at Script16.run(Script16.groovy:24)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:87)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I'm using SoapUI Pro 3.6, Build dist-109-2010-09-13, Build Date 2010/09/13 13:46.
It seems that the classpath is not extended. If I copy ojdbc14.jar to the SoapUI/lib dir it works. But I want to avoid that.
BhuvaneshMani
9 years agoNew Contributor
Many thanks, this worked as piece of cake :)
In my organisation, copying jar files to ${SOAPUI_HOME}\lib is restricted due to organisation policy in C:\Program Files\ folder. Hence i was forced to load all of my external jar files and this solution worked perfectly.
Related Content
- 4 years ago
- 4 years ago
- 3 years ago