cancel
Showing results for 
Search instead for 
Did you mean: 

Soapui is not loading external jar file --location added to classpath

SM
Not applicable

Soapui is not loading external jar file --location added to classpath

Hi
I don't want to add my jar files to bin/ext. Instead I tried to add the path to the soapui.bat as follows --
set CLASSPATH=%SOAPUI_HOME%soapui-2.5.jar;%SOME_SYS_VAR%\lib\*;

But when I run my testcases, soapui complains about mising class files. I made changes to testrunner.bat file too.
What am I missing here?

Thanks
10 REPLIES 10
rah
Occasional Contributor

Re: Soapui is not loading external jar file --location added to classpath

You can use the following statement in your soapUI Groovy Script to expand the classpath

com.eviware.soapui.support.ClasspathHacker.addURL( new URL("file://{path_to_your_jar_file}") )

before

import groovy.sql.Sql
etc.
maghol
New Contributor

Re: Soapui is not loading external jar file --location added

Hey,

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.
maghol
New Contributor

Re: Soapui is not loading external jar file --location added

Oops, I made a typo. The file name should be ojdbc14_g.jar.
ClasspathHacker works fine!
svreddyt
Occasional Contributor

Re: Soapui is not loading external jar file --location added

Hello there,

I tried with groovy script to connect DB but I got below exception...... any help is appriciated

Sat Nov 20 11:44:48 CST 2010:ERROR:groovy.lang.MissingPropertyException: No such property: dcsi for class: Script9
groovy.lang.MissingPropertyException: No such property: dcsi for class: Script9
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:239)
at Script9.run(Script9.groovy:15)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:88)
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)
BhuvaneshMani
New Contributor

Re: Soapui is not loading external jar file --location added

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.

LalMAnsari
New Contributor

Re: Soapui is not loading external jar file --location added to classpath

Were you able to find the resolution of your problem? I am facing the same problem but com.eviware.soapui.support.ClasspathHacker.addURL( new URL("jar file") ) is not working for me. I am still getting the same error.

rupert_anderson
Valued Contributor

Re: Soapui is not loading external jar file --location added to classpath

Hi,

 

In terms of setting an alternative location for the /ext folder (where jar files like drivers should normally be placed), I have previously just changed where SoapUI expects to find this folder by changing the following parameter:

-Dsoapui.ext.libraries=$SOAPUI_HOME/bin/ext

You can see that SoapUI also uses this parameter in its start scripts e.g. /java/app/bin/soapui.sh

 

if [ $SOAPUI_HOME != "" ]
then
    JAVA_OPTS="$JAVA_OPTS -Dsoapui.ext.libraries=$SOAPUI_HOME/bin/ext"
    JAVA_OPTS="$JAVA_OPTS -Dsoapui.ext.listeners=$SOAPUI_HOME/bin/listeners"
    JAVA_OPTS="$JAVA_OPTS -Dsoapui.ext.actions=$SOAPUI_HOME/bin/actions"
    JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$SOAPUI_HOME/bin"
	JAVA_OPTS="$JAVA_OPTS -Dwsi.dir=$SOAPUI_HOME/wsi-test-tools"
# uncomment to disable browser component
#   JAVA_OPTS="$JAVA_OPTS -Dsoapui.browser.disabled=true"
fi

Something similar works if running SoapUI via Maven e.g. 

 

mvn integration-test "-Dsoapui.ext.libraries=src/test/resources"

This isn't an answer to your ClasspathHacker issue, but does this help?

 

Cheers,

Rupert

Author of SoapUI Cookbook
BhuvaneshMani
New Contributor

Re: Soapui is not loading external jar file --location added to classpath

I am not sure if you have added correct path provided in "jar file" in below line.

com.eviware.soapui.support.ClasspathHacker.addURL( new URL("jar file") )

 

I tried with below code and it worked. 

Note: We require different set of jar files for different projects created in SOAP UI and hence we maintain the folder "jars" is same location of project xml and put all required jars inside jars folder.

 

 

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def classpathHacker = new com.eviware.soapui.support.ClasspathHacker()


path = groovyUtils.getProjectPath()
myfile = new java.io.File(path + "/jars/ojdbc7.jar")
mystring = "file://" + path + "/jars/ojdbc7.jar"

classpathHacker.addFile( myfile )
classpathHacker.addURL( new URL(mystring))

 

rupert_anderson
Valued Contributor

Re: Soapui is not loading external jar file --location added to classpath

Thats a fair point about needing a different set of jars per project, the /ext folder configuration is more of a global option. Athough, when running SoapUI from scripts (like Maven) the -Dsoapui.ext.libraries= could always be set to the project location when running each project.

 

Interesting option that ClasspathHacker anyway, so thanks for sharing the solution 🙂

Author of SoapUI Cookbook
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors