How to load Jar inside Groovy Script dyanmically ? I don't have the access to "../bin/ext" folder
I need to call a method inside Jar from groovy script inside SoapUI project.
Due to the lack of administrative access I can't place that jar in "../bin/ext" folder in SaopUI intall directory.
So the only option left is load the jar in runtime and call the method. Very simple approach.
I tried the below approach.
this.class.classLoader.rootLoader.addURL(new URL("file:///H://Foo-2//Foo.jar")); def cls = Class.forName("test").newInstance();cls.add()
This is not working as rootLoader is null.
second approach .
def classLoader = ClassLoader.systemClassLoaderdef newClassLoader = new URLClassLoader([new File("file:///H://Foo-2//Foo.jar") .toString().toURL()] as URL[], classLoader) def cls = Class.forName("test").newInstance();
this is not working too , it's giving me ClassNotFoundException.
I spent a day in this. even change the class name to lower case after seeing this thread.
What all the other option I have? What i am doing wrong?
Access issues are frustrating some times, aren't they? Sometimes the day is better spent trying to get somebody to just put the jar in the appropriate location for you.
If you can read your SoapUI install folder, but not write, can you make a copy of it somewhere else where you will have the ability to write the jars?
Or, can you bring the Java content of the jar into a Groovy Script?