I have a problem with running java code from groovy script (groovy script is a part of SoapUI test suite) i create simple script:
import myjar.jar
new TopClass().sayHello()
the code of TopClass:
public class TopClass {
public void sayHello (){
System.out.println("Hello");
}
}
I put myjar.jar into both soapui-pro-2.5\lib and soapui-pro-2.5\bin\ext folders. But running script I get:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script1.groovy: 2: unable to resolve class myjar.jar @ line 2, column 1.org.codehaus.groovy.syntax.SyntaxException: unable to resolve class myjar.jar @ line 2, column 1. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:113) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:970) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) at org.codehaus.groovy.control.CompilationUnit$5.call(CompilationUnit.java:527) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:772) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:438) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:281) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:572) at groovy.lang.GroovyShell.parse(GroovyShell.java:584) at groovy.lang.GroovyShell.parse(GroovyShell.java:564) at groovy.lang.GroovyShell.parse(GroovyShell.java:603) at
Please help me to find what I'm doing wrong
Putting the jar under soapui-pro-2.5\bin\ext
is all you need for the classes to be found (although restarting SoapUI
won't hurt).
However - you should check that the error you get is related to your jar. Is com.my.research
available within myjar.jar
? If no - just add it.
If yes, add more detailed information to your post.
import myjar.jar
I believe this is not correct, you should be importing the name of the java package not the name of the jar. Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With