7

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

Oleksandr Martynov
  • 320
  • 2
  • 5
  • 19

3 Answers3

6

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.

RonK
  • 9,472
  • 8
  • 51
  • 87
  • yes, it available - in fact, that is the only package in jar. According to console myjar is added to classpath: [SoapUI] Adding [/opt/soapui-4.5.0/bin/ext/myjar.jar] to extensions classpath . . after script start I get: . . org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script6.groovy: 1: unable to resolve class com.my.research @ line 1, column 1. import com.my.research – Oleksandr Martynov Apr 28 '12 at 22:28
  • 2
    When you use `import` you can either import a single class `import com.my.research.MyClass` or an entire package `import com.my.research.*` - you seem to have done neither. Try one of those and update us on the result. – RonK Apr 29 '12 at 04:33
1

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

Philippe
  • 446
  • 2
  • 12
  • the same error( `org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script2.groovy: 2: unable to resolve class com.my.research` – Oleksandr Martynov Apr 28 '12 at 12:53
0

On non-windows implementations of soapui I find it helps if you add it to the .sh file that starts soapui explicitly.

sweetfa
  • 5,457
  • 2
  • 48
  • 62