Contributions
Re: How to load Jar inside Groovy Script dyanmically ? I don't have the access to "../bin/ext" folder
JHuntThanks for the response, Yes they are frustrated. I am going to this thread.and change my code to this. def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def classpathHacker = new com.eviware.soapui.support.ClasspathHacker () log.info "utils=" + groovyUtils mystring = "file://H://Baz.jar" com.eviware.soapui.support.ClasspathHacker.addURL( new URL(mystring) ) def cls = new bar() log.info cls Still not resolved. Any help. My super simple Jar source code public class bar { public static void main(String[] args) { add(); } public static void add(){ String path = "H:" + File.separator + "Groovy" + File.separator + "hi.txt"; File f = new File(path); f.getParentFile().mkdirs(); try { f.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }6.3KViews0likes0CommentsHow 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?Solved6.4KViews1like2Comments