Ask a Question

How to import external java classes in SoapUI 5.0.0 ?

vikram_9669
Occasional Contributor

How to import external java classes in SoapUI 5.0.0 ?

I am trying to import some external java classes in my groovy script. All these classes are located under "C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\ext\DDDD" folder.

I am getting an error "unable to resolve class ITDConnection@ line 4, column 15 ITDConnection itdc= ClassFactory.createTDConnection()" for below code

 

import com4j.*;
import DDDD.*;

ITDConnection itdc = ClassFactory.createTDConnection()
itdc.initConnectionEx(url)

 

SoapuiError.jpg

8 REPLIES 8
rupert_anderson
Valued Contributor

Hi,

 

That looks ok, at least at first glance...

 

If you take this example of importing the H2 DB driver:

 

import groovy.sql.Sql
import org.h2.Driver

com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("org.h2.Driver")
def db = Sql.newInstance("jdbc:h2:mem:test", "org.h2.Driver")

...

 

If I don't add the h2-1.4.181.jar (for the org.h2.Driver class, groovy.sql.Sql is already in the SoapUI lib folder) then I get the same error as you i.e. unable to resolve class.

 

If I then add h2-1.4.181.jar to <SoapUI Installation Directory>/java/app/bin/ext/ (Mac) then the code compiles and runs fine.

 

I can't see your ITDConnection class in the screenshot though?

 

Cheers,

Rupert

Author of SoapUI Cookbook

Hang on, are you providing your DDD classes just as a folder rather than a jar file? I can't quite remember, but I think the SoapUI ext class loader might only scan for *.jar files to add to the classpath...

 

Hope this helps.

Cheers,

Rupert

Author of SoapUI Cookbook

Hi Rupert,

 

There are more than 200 java classes at this location. Not able to get all of them in one screenshet.

But, yes ITDConnection class is present at this location "C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\ext\DDDD"

Hi,

 

No problem about the screen shot.

 

Is DDDD just a folder rather than a jar file? because I think it might need to be a jar file to get picked up.

 

Cheers,

Rupert

Author of SoapUI Cookbook

 

Hey Rupert,

 

Yeah, it was a folder. I have created jar file for all classes in this folder and imported that jar in the script. That worked!!

Thanks You so much.

 

-Vikram

Also do you see the following log message (SoapUI log tab) once SoapUI has started:

 

Wed May 06 16:05:30 BST 2015:INFO:Adding [/Applications/SoapUI-5.1.3.app/Contents/Resources/app/bin/ext/h2-1.4.181.jar] to extensions classpath

 

(it should say DDDD.jar rather than h2-1.4.181.jar in your case, assuming its picked your DDDD.jar up)

 

Having just checked the code in SoapUIExtensionClassLoader I can confirm that your classes need to be in a jar file to get picked up from the /ext folder.

 

Cheers,

Rupert

Author of SoapUI Cookbook

Ah, just seen your reply! 

 

Ok, cool, happy to help 🙂

 

Cheers,

Rup

Author of SoapUI Cookbook

Hi Vikram,

 

I am also trying to crate  all my common functions in Groovy jar file and need to import to SoapUI 5.0 free version.

Could you please help me how can i achieve this one.

 

Thanks

Babu

cancel
Showing results for 
Search instead for 
Did you mean: